目前使用此代码获取"csrfPreventionSalt"
Struts2中Interceptor的参数值。
谁能告诉一个直接的方法来获取它的价值......
public String intercept(ActionInvocation invocation) throws Exception {
final ActionContext context=invocation.getInvocationContext();
HttpServletRequest httpReq = ServletActionContext.getRequest();
String salt ="";
Map<String, Object> params = (Map<String, Object>)ActionContext.getContext().getParameters();
Iterator<Entry<String, Object>> it = (Iterator<Entry<String, Object>>)params.entrySet().iterator();
while(it.hasNext()) {
Entry<String, Object> entry = it.next();
if(entry.getKey().equals("csrfPreventionSalt"))
{
Object obj = entry.getValue();
if (obj instanceof String[]){
String[] strArray = (String[]) obj;
if (strArray!=null) {
salt = strArray[0];
}
}
}
}