以下是我将一个比较老旧的项目从Struts2.1.7升级到2.3的过程。
一、更新jar包
将下列jar包进行更新,原来项目上有的就替换成新版的,没有的就添加上去。
二、更改struts.xml
将2.1.7换成2.3
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
更改完后启动进行测试发现出现: java.lang.ClassNotFoundException: Login!loginAction,查了资料,原来已有的action突然找不到,原来新的struts2默认禁用,动态调用action方法
because struts2.3.15.1升级后 s:submit method not work action’s method
要在struts.properties里面加
struts.enable.DynamicMethodInvocation = true
或者
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
如下图: