首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

struts2 token兑现方式

2012-06-26 
struts2 token实现方式1 ??? struts2 的token标签 会在页面产生?public static final String DEFAULT_TOKE

struts2 token实现方式

1

??? struts2 的token标签 会在页面产生

?

public static final String DEFAULT_TOKEN_NAME = "struts.token"; public static final String TOKEN_NAME_FIELD = "struts.token.name"; public static String setToken(String tokenName) { Map session = ActionContext.getContext().getSession(); String token = generateGUID(); try { session.put(tokenName, token); } catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); } return token; }?这样就只能这里的tokenName竟然是一个变量量,这样的话,就解决了不同页面的key不一样,对一个页面进行表单重复提交 进行验证,如果出现两个页面 同时添加的时候,就不能都是 默认,不然会使另外一个页面失去有效

----------------------承接java 项目
java web ,
java 中间件开发
电话 13534066735
QQ?? 239052343

热点排行