struts2常见错误总结

1. Console错误: Exception starting filter struts2
   No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public void com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.setObjectFactory(com.opensymphony.xwork2.ObjectFactory). - Class: com.opensymphony.xwork2.inject.ContainerImpl
File: ContainerImpl.java
解决:struts.xml位置不对。


2. Console错误:Exception starting filter struts2
java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
解决:缺少包:commons-lang3-3.1.jar

3. Console错误:Could not create JarEntryRevision for[jar:file:D:/application/apache-tomcat-6.0.30/webapps/SSH1/WEB-INF/lib/struts2-core-2.3.4.jar]!
java.lang.NoClassDefFoundError:org/apache/commons/io/FileUtils
缺少包:commons-io-2.0.1.jar

4. Console错误:Dispatcher initialization failed
java.lang.RuntimeException:java.lang.reflect..InvocationTargetException
缺少包:javassist-3.11.0.GA.jar

5. Console错误:Caught exception while loading file struts-default.xml - [unknown location]
解决:由于lib包冲突造成的,将两个解析xml用的jar从项目里移到tomacat的lib下面就ok了,xml-apis.jar xerces-2.6.2.jar

6. Console错误:Exception starting filter struts2
 Error building results for action login in namespace  - action - file:/E:/apache-tomcat-6.0.14/webapps/testStruts2/WEB-INF/classes/struts.xml57
原因:在web.xml已声明使用模板,并对所有的类进行了监听,但在处理过程中,发现不知道到哪里去找模板的配置文件,即在struts.xml中已使用了模板,但并没有告诉程序应该到哪去解析这些内容,即titles-default.java文件应该声明出来,

 原因1:在struts.xml中错误的声明如下:
 
 showWelcomePage

 应改为:
 
 showWelcomePage

 原因2:titles.xml文件的 错误配置
 
                          
               menu_1.jsp                 
               login_form.jsp

 正确配置如下 :

 在value属性中,以"/"开头表示地址,如果不以“/”开头,则系统会默认为内容

7. 执行增加操作时,直接对对象进行操作,对象中各字段值都正确,但插入数据库后乱码
 解决(1) 统一页面和数据库编码为utf-8
 (2)修改hibernate的配置文件,修改url属性为:
 jdbc:mysql:/127.0.0.1:3306/shop?useunicode=true&characterEncuoding=utf-8

8. 在进行页面跳转时,已经跳转到了相应的页面,但显示结果页面不正确。
解决:检查模板中的各个属性是否正确配置,尤其注意有的属性会忘记配置。

9. Nosuchdefinition titles...
解决: tiles.xml文件中的配置有问题,尤其注意name属性

10. No result defined for action ***Action and result success
解决:这个错误产生的原因是,在struts.xml中配置没有配置success result。我的理解是action执行完后,必须产生一个result类。这个类可是servlet或是其他,但不能为空。
     解决方法:增加result success定义。
     ***.jsp

11. No result defined for action ***Action and result input
解决:这个错误,在提交数据时经常碰到。定义的struts2 intercept发挥了作用,当POJO类型与输入的类型不同时,intercept类会中止拦截,并返回输入页面。详细的错误可在使用来获取。
     解决方法:增加resut input定义。
     ***.jsp

12. There is no Action mapped for namespace / and action name ***Action
解决:可以直译为没有找到这个action,也就是说在struts.xml中没有定义这个action。这个错误一般是action的名字拼写错误造成的,请仔细检查struts.xml的定义与页面的acrion是否一致。

13. Class ognl.OgnlRuntime can not access a member of class ***Action with modifiers "private"
解决:关键字是"private",action类中的字段为private,这样页面(如jsp)是无法访问到的,这也是struts2面向对象的一大特征。
     在action中添加set get方法,这样struts会自访问这个方法。set get方法必须遵循bean的标准写法。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值