带有DOJO插件的Struts 2.3.15不起作用

时间:2016-03-07 13:51:50

标签: java struts2 dojo

我正在尝试使用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";
}
}  

注册-validation.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

我希望这些信息足够。谢谢任何回复:)

1 个答案:

答案 0 :(得分:0)

你有两个不同版本的dojo插件库。版本2.3中不推荐使用Dojo插件。清理WEB-INF/lib

  • struts2的-道场-插件-2.3.1.2.jar
  • struts2的-道场-插件-2.1.8.jar

如果您使用的是Struts 2.3.24,则版本应该在plugin-之后。请参阅this回答,了解您可以使用哪个库而不是dojo插件。