这一个异常相信会有同志跟我一样遇到过,往往,浏览器里还会出现一段话:
The server encountered an internal error (No action instance for path /user could be created) that prevented it from fulfilling this request
意味着客户端的请求根本发不到服务器,因为,请求路径不能创建(注意,以这样的方式去理解上面一段话会比较合理一点)。
而tomcat这边却什么事都没有,一点提示信息都不给。这就搞得我一肚子肝火!瞪直了眼睛四处找异常,从struts-config.xml到web.xml,
找了半天得出结论是自己的配置没有问题。然后不管是我baidu,还是Google,发现没有一个人给出合理的解释。都一个劲的认为是上面两个
配置文件的问题,要么就说action的package出问题。仔细一看,发现往往解决方案都是出自一个人的手里,只不过呆在不同人的blog而已,真
的是一塌糊涂。
还是决定,自已的问题自己解决,不久在自己的调式过程中就发现,每次我试图在继承Action的子类的构造函数实例化某个成员的时候,上面
鬼怪的异常就出现了,当我toggle comment实例化语句,这一个问题就没有了。原来问题出在这里,为了证实自己的想法,立马翻了一下struts
的api,查Action,发现这么一段话
Actions must be programmed in a thread-safe manner, because the controller will share the same instance for multiple simultaneous requests. This means you should design with the following items in mind:
Instance and static variables MUST NOT be used to store information related to the state of a particular request. They MAY be used to share global resources across requests for the same action.
Access to other resources (JavaBeans, session variables, etc.) MUST be synchronized if those resources require protection. (Generally, however, resource classes should be designed to provide their own protection where necessary.
原来一开始自己就没有遵循Action类继承的原则,即要以线程安全的编程方式去编码。也就是说,Action作为一个全局唯一的控制Servlet,所有的实例对象只能在Action自身有一个唯一的副本,能够同时让多个请求共享同一个实例,而不能为某一个特别的请求实例化成员。
[/size][size=x-small][color=blue][/color]
分享到:
相关推荐
(the last one can be overridden for the implementation of new alignment rules). - ADD: The property TFlexPanel.GridControl moved to the public section and is now available for writing (during the ...
special sections cannot be overridden by user-defined INI files or ; at runtime. Currently, [PATH=] and [HOST=] sections only work under ; CGI/FastCGI. ; http://php.net/ini.sections ; Directives are...
- Minor changes to the No operation error watchdog timer for the CD and Hard disk tests. - Minor correction to the Butterfly seek test. - Video playback trace logging increased. Release 5.3 build ...
active filter state and no filter state, as an alternative for 'Clear All Filters', which doesn't allow you to return back the filters. * Version 1.70: o Added /sort command-line option for ...