struts2 spring issue list

1、关于调用struts的action时出现如下错误:
No thread-bound request found: Are you referring to request attributes outside of an actual web request? If you are actually operating within a web request and still receive this message,your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, useRequestContextListeneror RequestContextFilter to expose the current request.
必然,这个错误是由于IOC引起的,如果不用IOC的方式,这个错误就不会出现。一种出现该错误的情况在于你的Action配置了 session,request或则response。大家都知道在struts2中,request和response的实现机制已经大不一样了,不以参数的形式存在于方式之中,而是通过实现SessionAware, ServletRequestAware,ServletResponseAware接口的set方法实现的
不管怎么样,解决办法是有的,其实该错误本身就说了解决办法(useRequestContextListeneror RequestContextFilter to expose the current request):
在web.xml中添加:

Xml代码 
  1. <listener>  
  2.     <listener-class>  
  3.         org.springframework.web.context.request.RequestContextListener  
  4.     </listener-class>  
  5. </listener>  


重新启动,你会发现,现在错误没有了。

 

 

2

之前在用struts2.0做表单提交时,为了防止重复提交,使用了自带的token拦截器。拦截器的配置很简单,但是,不知道为什么,使用拦截器后,原本和struts绑定的bean无法完成数据的绑定,每次回action取bean中的内容均为null,实在让人郁闷。 

后来,发现需要再加上一个默认的拦截器

重新启动 问题解决了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值