[英]get list view with specific records from server based on email address sent from android
[英]Get a specific parameter sent from view in interceptor
當前使用此代碼在Struts2中獲取Interceptor的參數"csrfPreventionSalt"
的值。
任何人都可以告訴直接獲取價值的方法...
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];
}
}
}
}
假定參數已發送給操作,而不是發送給攔截器。 調用動作時,將創建動作上下文,並將請求中的參數復制到動作上下文。 您可以通過獲取參數
public String intercept(ActionInvocation invocation) throws Exception {
final ActionContext context = invocation.getInvocationContext();
Map<String, Object> parameters = context.getParameters();
String[] values = (String[]) parameters.get("csrfPreventionSalt");
String salt = values[0];
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.