Java 找不到引用名jsonValidationWorkflowStack引用的侦听器类
在我的Struts2应用程序中,我在Java 找不到引用名jsonValidationWorkflowStack引用的侦听器类,java,struts2,struts2-json-plugin,struts2-interceptors,Java,Struts2,Struts2 Json Plugin,Struts2 Interceptors,在我的Struts2应用程序中,我在struts.xml 链接 web.xml 支柱2 支柱2 org.apache.struts2.dispatcher.FilterDispatcher 支柱2 /* index.jsp jsp/login/login.jsp 30 org.apache.tiles.impl.basictelescontainer.DEFINITIONS\u CONFIG /WEB-INF/tiles.xml org.apache.struts2.tiles.StrutsT
struts.xml
链接
web.xml
支柱2
支柱2
org.apache.struts2.dispatcher.FilterDispatcher
支柱2
/*
index.jsp
jsp/login/login.jsp
30
org.apache.tiles.impl.basictelescontainer.DEFINITIONS\u CONFIG
/WEB-INF/tiles.xml
org.apache.struts2.tiles.StrutsTilesListener
拦截器ref
标记的主体不应为空,因此需要简化其使用
<interceptor-ref name="jsonValidationWorkflowStack"/>
json插件在运行时应该位于类路径上 错误表明您没有将struts2 json插件jar文件放在类路径中(即
WEB-INF/lib
)。获取struts2-json-plugin-2.3.20.jar
并将其放在类路径中以解决问题。如果您下载了struts2 Jar,那么可以将此Jar文件视为下载包的一部分
在检查您提供的时,如果您想使用Struts2-2.3.20
,我发现了一些问题
1) struts.xml
中的DOCTYPE
声明不正确。应该是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="default" extends="json-default">
<action name="login" class="com.examples.action.LoginAction">
<interceptor-ref name="jsonValidationWorkflowStack"></interceptor-ref>
<result name="input" type="json">
<param name="ignoreHierarchy">false</param>
<param name="includeProperties">actionErrors\[\d+\], fieldErrors\..+$,
actionMessages\[\d+\]</param>
</result>
</action>
</package>
</struts>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN"
"http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
现在来看插件,如果类路径中没有JSON插件,则会出现运行时异常,如下所示:
Caused by: Parent package is not defined: json-default
要修复此问题,请在应用程序的WEB-INF/lib
中添加struts2-json-plugin-2.3.20
,使其位于类路径中
现在,由于JSP页面使用JQuery标记,您必须将struts2-JQuery-plugin-2.5.3.jar
放在类路径中
我已经用
Struts2-2.3.20
版本对其进行了测试,请更正您的代码,看看这是否解决了问题。否,仍然是相同的错误。.我在您的链接上看不到的是web.xml
。你能把它贴到问题上吗?jsonValidationWorkflowStack的类名是什么,这样我就可以在插件中检查该类名了。我使用的是struts2-json-plugin-2.1.8.1 jar文件我添加的web.xml是我使用的,它不是来自我为不同Struts版本提供的链接,所以你不能使用它。另请参见,因为org.apache.struts2.dispatcher.FilterDispatcher
已被弃用。您需要提供更多信息。您的doctype是错误的。@AleksandrM,哪一个?根据此链接,我的答案中的验证doctype是正确的-->所有这些。没有检查链接。这是过时的教程。@Chaitanya谢谢你的回答,我还没有注意到struts2json jar版本,链接中提到的我使用的struts2json插件是导致我出现问题的原因
Caused by: Parent package is not defined: json-default