Struts2动态方法调用出错

来源:互联网 发布:linux中解压缩命令 编辑:程序博客网 时间:2024/05/19 22:01


 昨天看马士兵的视频,里面讲到struts动态调用方法,然后自己把马士兵里面的所有除jar包以外的所有文件考过来,结果发现提示如下错误:

Struts Problem Report

Struts has detected an unhandled exception:

Messages:
  • There is no Action mapped for namespace [/user] and action name [userAdd!add] associated with context path [/StrutsJar].

  • 自己弄了很久都没有弄好!!最后经过通宵达旦工作,并找度娘和同学请教,终于找到两种方法解决该问题:
    第一种方法
    拷贝下述语句:
    <constant name="struts.enable.DynamicMethodInvocation" value="true" />
    ,将上面的这条语句加入到struts标签里面,结果问题就解决了!!

    第二种方法:
    将struts2.3.16的struts-core-2.3.16.jar文件从项目中彻底删除,并将马老师的struts-core-2.1.6.jar文件拷贝到项目中,这里说的彻底删除的意思是保证该tomcat下的该web应用的lib文件夹下面没有struts-core-2.3.16.jar文件,如果没有将struts-core-2.3.16.jar彻底删除,会出现如下错误:
    Unable to load configuration. - bean - jar:file:/C:/apache-tomcat-6.0.37/webapps/StrutsJar/WEB-INF/lib/struts2-core-2.3.16.jar!/struts-default.xml:40:72;
    该错误的原因是因为该web应用下有两个struts2-core-##.jar文件,所以我们此时就要到tomcat里面去找是不是真的有这样两个jar文件,并删除一个,这里我们删除struts2-core-2.3.16.jar,导入struts2-core-2.1.6.jar到项目中,并同时导入
    xwork-2.1.2.jar到web项目中,否则出现class method not found的错误;



    这里顺便加一下我MyEclipse报的错:
    There is no Action mapped for namespace [/user] and action name [userAdd!add

    0 0
    原创粉丝点击