📄 tokentag.java
字号:
/* * Copyright (C) butor.com. All rights reserved. * * This software is published under the terms of the GNU Library General * Public License (GNU LGPL), a copy of which has been included with this * distribution in the LICENSE.txt file. */package org.butor.web.taglib.html;import java.io.IOException;import javax.servlet.jsp.JspException;import javax.servlet.jsp.JspWriter;import javax.servlet.jsp.tagext.TagSupport;import org.apache.struts.action.Action;import org.butor.log.Log;import org.butor.web.Constants;import org.butor.web.context.IWebContext;import org.butor.web.context.WebContextService;/** * Put token in form to be submitted and checked by an intereseted action. * * @author Aiman SAWAN */public class TokenTag extends TagSupport { /** * @see Tag#doStartTag() */ public int doStartTag() throws JspException { IWebContext context = WebContextService.getContext(); if (context == null){ Log.logStr(this, Log.LOG_TYPE_ERROR, "doStartTag()", "Got null context!"); return EVAL_PAGE; } JspWriter writer = pageContext.getOut(); if (writer == null) { Log.logStr(this, Log.LOG_TYPE_ERROR, "doStartTag()", "Got null JspWriter!"); return EVAL_PAGE; } try { writer.print("<input type=\"hidden\" name=\""); writer.print(Constants.TOKEN); writer.print("\" value=\""); writer.print(context.readProperty(Constants.TOKEN)); writer.println("\"/>"); } catch (IOException e) { throw new JspException(e.toString()); } return EVAL_PAGE; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -