1.异常:
ava.lang.NoSuchMethodError: com.opensymphony.xwork2.ActionContext.get(Ljava/lang
2. 原因:
由于xwork2.0 版本和 xwork2.3版本中方法 不一致,其中2.0中是get(Object param) ,而 2.3版本中是get(String param);导致出错。
3. 解决方法:
①:查看网址: https://www.aliyun.com/jiaocheng/334901.html
②: 转发上边网址:
-
struts2.1.8不认jsonplugin插件解决办法
我用到了struts的最新版本2.1.8,第一次用新版本,对新版本的改动还不很了解。
只加入了以下jar包:
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging-1.0.4.jar
freemarker-2.3.15.jar
ognl-2.7.3.jar
spring-test-2.5.6.jar
struts2-core-2.1.8.jar
xwork-core-2.1.6.jar
这两天用到了json插件,我按照以前的版本加入jsonlugin插件,但是搞了一天struts 的action就是不认json插件,第二天换用2.1.6版本的包却可以使用,又换回2.1.8版本还是不行,最后在下载好的lib文件夹里找到了以下jar包:
json-lib-2.1.jar
struts2-json-plugin-2.1.8.jar
struts2-junit-plugin-2.1.8.jar
上面三个包加入项目里之后,再删除jsonplugin-0.33.jar包
一切都运行正常了
以上是java.lang.NoSuchMethodError: com.opensymphony.xwork2.ActionContext.get(Ljava/lang/Object;)的内容,更多 的 strutsobject 的内容,请您使用右上方搜索功能获取相关信息。
③:我项目中pom.xml中的jar包,无报错。可引用;
<!-- struts核心包: begin.. -->
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.freemarker/freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.17.0-GA</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ognl/ognl -->
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
<version>2.7.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.struts.xwork/xwork-core -->
<dependency>
<groupId>org.apache.struts.xwork</groupId>
<artifactId>xwork-core</artifactId>
<version>2.2.1</version>
</dependency>
<!-- struts核心包:end.... -->
<!-- json需要的包 begin... -->
<!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-collections/commons-collections -->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<!-- <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1</version>
</dependency> -->
<!-- https://mvnrepository.com/artifact/net.sf.ezmorph/ezmorph -->
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sf.json-lib/json-lib -->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<!--没有设置jdk版本设置,不能使用,特别注意。 -->
<classifier>jdk15</classifier>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-json-plugin -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>2.1.8</version>
</dependency>
<!-- json需要的包 end... -->