struts2对action中的某个方法拦截后,传递过来的参数怎么获取?

jiahardstudy 2010-09-19 02:12:15
点击某个按钮调用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";
}
谢谢!
...全文
275 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiahardstudy 2010-09-19
  • 打赏
  • 举报
回复
解决了 谢谢!
  • 打赏
  • 举报
回复
学习下
jumpheightway 2010-09-19
  • 打赏
  • 举报
回复
配置参数拦截器不就可以了
redlotus_lyn 2010-09-19
  • 打赏
  • 举报
回复
<action name="dispatchSellChance" class="sellchanceSpring" method="DispatchSellChance">
<interceptor-ref name="myInterceptor"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="dispatch">/page/dispatch.jsp</result>
</action>

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧