struts2对action中的某个方法拦截后,传递过来的参数怎么获取?
点击某个按钮调用javascript脚本
function dispatch(scId){
window.location.href="dispatchSellChance!DispatchSellChance.action?sellChance.scId="+scId;
}
进入struts.xml文件
<action name="dispatchSellChance" class="sellchanceSpring" method="DispatchSellChance">
<interceptor-ref name="myInterceptor"></interceptor-ref>
<result name="dispatch">/page/dispatch.jsp</result>
</action>
对DispatchSellChance方法进行拦截进入自定义拦截器
public String intercept(ActionInvocation invocation) throws Exception {
System.out.println("进入拦截器");
ActionContext context=invocation.getInvocationContext();
Map<String,Object> map=context.getSession();
Personnel personnel=(Personnel)map.get("per");
if(personnel==null){
return "noway";
}
return invocation.invoke();
}
操作成功程序运行到return invocation.invoke();后进入action中的DispatchSellChance方法
public String DispatchSellChance(){
System.out.println(sellChance+"*********");//该对象为空,没有将sellChance.scId的值传递到这个action中
应该怎么实现
SellChance listSellChance=sellChanceBizImpl.findByScId(sellChance.getScId());
List<Personnel> listPersonnel=personnelBizImpl.findAll();
this.getRequest().setAttribute("listSellChance", listSellChance);
this.getRequest().setAttribute("listPersonnel", listPersonnel);
return "dispatch";
}
谢谢!