带有 DOJO 插件的 Struts 2.3.15 不起作用
Posted
技术标签:
【中文标题】带有 DOJO 插件的 Struts 2.3.15 不起作用【英文标题】:Struts 2.3.15 with DOJO plugin isn't working 【发布时间】:2016-03-07 13:51:50 【问题描述】:我正在尝试使用 dojo 插件在 Struts 2 中构建一个应用程序,但我无法使其工作。
Index.jsp
文件有 3 个文本框,这些文本框使用注册验证命名类文件进行验证。
Index.jsp:
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/struts-dojo-tags" prefix="d"%>
<html>
<head>
<d:head/>
</head>
<body>
<marquee>Registration Form.............</marquee>
<s:form action="register">
<s:textfield name="name" label="Username"></s:textfield>
<s:textfield name="email" label="Email ID"></s:textfield>
<s:password name="password" label="Password"></s:password>
<d:submit >
</d:submit>
</s:form>
</body>
</html>
Register.java:
package example;
import com.opensymphony.xwork2.ActionSupport;
public class Register extends ActionSupport
private String name,password,email;
//setters and getters
public String execute()
return "success";
注册验证.xml:
<validators>
<field name="name">
<field-validator type="requiredstring">
<message>Name can't be blank</message>
</field-validator>
</field>
<field name="email">
<field-validator type="requiredstring">
<message>Email ID can't be blank</message>
</field-validator>
<field-validator type="email">
<message>Please enter a valid email ID</message>
</field-validator>
</field>
<field name="password">
<field-validator type="requiredstring">
<message>Password can't be blank</message>
</field-validator>
<field-validator type="stringlength">
<param name="minLength">5</param>
<param name="maxLength">10</param>
<message>Password can't be less than 5 or greater than 10</message>
</field-validator>
</field>
</validators>
Sturts.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<package name="a" extends="struts-default">
<action name="register" class="example.Register">
<interceptor-ref name="jsonValidationWorkflowStack"></interceptor-ref>
<result name="success">welcome.jsp</result>
<result name="input">index.jsp</result>
</action>
</package>
</struts>
Web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>example/HelloWorld.jsp</welcome-file>
</welcome-file-list>
</web-app>
错误日志:
07-Mar-2016 19:08:50.038 INFO [http-nio-8084-exec-33] org.apache.catalina.util.LifecycleBase.stop The stop() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Ajaxva]] after stop() had already been called. The second call will be ignored.
07-Mar-2016 19:08:50.539 INFO [http-nio-8084-exec-33] org.apache.catalina.startup.HostConfig.undeploy Undeploying context [/Ajaxva]
07-Mar-2016 19:08:50.571 INFO [http-nio-8084-exec-29] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Users\Sumit\AppData\Roaming\NetBeans\8.1\apache-tomcat-8.0.27.0_base\conf\Catalina\localhost\Ajaxva.xml
07-Mar-2016 19:08:50.571 WARNING [http-nio-8084-exec-29] org.apache.catalina.startup.SetContextPropertiesRule.begin [SetContextPropertiesRule]Context Setting property 'antiJARLocking' to 'true' did not find a matching property.
07-Mar-2016 19:08:51.187 INFO [http-nio-8084-exec-29] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
07-Mar-2016 19:08:51.441 INFO [http-nio-8084-exec-29] com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.info Parsing configuration file [struts-default.xml]
07-Mar-2016 19:08:51.557 INFO [http-nio-8084-exec-29] com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.info Parsing configuration file [struts-plugin.xml]
07-Mar-2016 19:08:51.610 SEVERE [http-nio-8084-exec-29] org.apache.struts2.dispatcher.Dispatcher.error Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/D:/Ajaxva/build/web/WEB-INF/lib/struts2-dojo-plugin-2.3.1.2.jar!/struts-plugin.xml:29:119
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:193)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4583)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:460)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1586)
at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1460)
at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:906)
at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:344)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: Unable to load bean: type:org.apache.struts2.views.TagLibrary class:org.apache.struts2.dojo.views.DojoTagLibrary - bean - jar:file:/D:/Ajaxva/build/web/WEB-INF/lib/struts2-dojo-plugin-2.3.1.2.jar!/struts-plugin.xml:29:119
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:226)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 53 more
Caused by: Bean type interface org.apache.struts2.views.TagLibrary with the name sx has already been loaded by bean - jar:file:/D:/Ajaxva/build/web/WEB-INF/lib/struts2-dojo-plugin-2.1.8.jar!/struts-plugin.xml:29:119 - bean - jar:file:/D:/Ajaxva/build/web/WEB-INF/lib/struts2-dojo-plugin-2.3.1.2.jar!/struts-plugin.xml:29:119
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:229)
... 56 more
07-Mar-2016 19:08:51.626 SEVERE [http-nio-8084-exec-29] org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start. Full details will be found in the appropriate container log file
07-Mar-2016 19:08:51.626 SEVERE [http-nio-8084-exec-29] org.apache.catalina.core.StandardContext.startInternal Context [/Ajaxva] startup failed due to previous errors
07-Mar-2016 19:08:51.641 INFO [http-nio-8084-exec-29] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor C:\Users\Sumit\AppData\Roaming\NetBeans\8.1\apache-tomcat-8.0.27.0_base\conf\Catalina\localhost\Ajaxva.xml has finished in 1,070 ms
我有以下库: -List item Struts 2 core 2.3.15
列表项 Struts 2 dojo 插件 2.3.24我希望这么多信息就足够了。提前感谢您的任何回复:)
【问题讨论】:
S2 dojo 插件已弃用。 【参考方案1】:您有两个不同版本的 dojo 插件库。 Dojo 插件在版本 2.3
中已弃用。清理WEB-INF/lib
:
如果您使用的是 Struts 2.3.24,则版本应该紧跟在 plugin-
之后。请参阅this 回答以了解您可以使用哪个库来代替 dojo 插件。
【讨论】:
以上是关于带有 DOJO 插件的 Struts 2.3.15 不起作用的主要内容,如果未能解决你的问题,请参考以下文章