首先,我不得不承认自己是个货真价实的小白,由于公司有现成的框架,来公司的几个月基本都只是做了一些代码填充的活,看过了研磨struts2,认为搭建一个struts2应该很简单的,结果发现自己错了。。。在这个过程中遇到很多不明问题,多亏了网上的大大们,现在总结如下,我想应该对想入门JAva ee的小伙伴们有些许帮助:
1、struts2拦截器启动error
原因:由于使用了struts2.3版本,其中有些东西都变了,引用struts2 filter-class 应该是org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter,而不是以前的org.apache.struts2.dispatcher.filterDiapatcher
注意引入javassits-3.xxx.jar和common-lang3.x.xx.jar:这两个jar包可以根据tomcat的提示轻松找出!
2、找不到action或者是result,这是配置问题
如:
type Status report
message There is no Action mapped for namespace [/] and action name [MyTestAction] associated with context path [/myTest].
description The requested resource (There is no Action mapped for namespace [/] and action name [MyTestAction] associated with context path
[/myTest].) is not available.
原因:没有配置struts.xml 没有配置结果集
解决办法:添加了namespace 和result 的name熟悉,解决,
3、要注意struts.xml必须放在 Java Resource 文件目录下面,其他文件目录无效、且名字不可更改!
这就是我第一次配置简单struts2框架所遇到的全部问题!虽然很简单,但还是希望对小伙伴们有帮助!