我正在尝试学习在 struts2 中使用 session 。所以,我只想实现一个登录/注销、配置文件应用程序。我正在关注互联网上提供的基本教程。但是,它根本不起作用。请帮助我解决以下问题如何解决。

Sep 19, 2015 5:44:12 PM org.apache.catalina.core.StandardContext listenerStart 
SEVERE: Error configuring application listener of class org.apache.struts2.tiles.StrutsTilesListener 
java.lang.NoClassDefFoundError: org/apache/tiles/listener/TilesListener 
    at java.lang.ClassLoader.defineClass1(Native Method) 
    at java.lang.ClassLoader.defineClass(Unknown Source) 
    at java.security.SecureClassLoader.defineClass(Unknown Source) 
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818) 
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) 
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415) 
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397) 
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118) 
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4638) 
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204) 
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 
Caused by: java.lang.ClassNotFoundException: org.apache.tiles.listener.TilesListener 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) 
    ... 17 more 
 
Sep 19, 2015 5:44:12 PM org.apache.catalina.core.StandardContext listenerStart 
SEVERE: Skipped installing application listeners due to previous error(s) 
Sep 19, 2015 5:44:12 PM org.apache.catalina.core.StandardContext startInternal 
SEVERE: Error listenerStart 
Sep 19, 2015 5:44:12 PM org.apache.catalina.core.StandardContext startInternal 
SEVERE: Context [/Login] startup failed due to previous errors 
Sep 19, 2015 5:44:13 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider info 
INFO: Parsing configuration file [struts-default.xml] 
Sep 19, 2015 5:44:13 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider info 
INFO: Unable to locate configuration files of the name struts-plugin.xml, skipping 
Sep 19, 2015 5:44:13 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider info 
INFO: Parsing configuration file [struts-plugin.xml] 
Sep 19, 2015 5:44:13 PM com.opensymphony.xwork2.util.DomHelper warn 
WARNING: Local DTD is missing for publicID: -//Apache Software Foundation//DTD Struts Configuration 2.5//EN - defined mappings: {-//Apache Struts//XWork 1.0//EN=xwork-1.0.dtd, -//Apache Struts//XWork 1.1.1//EN=xwork-1.1.1.dtd, -//Apache Struts//XWork 2.0//EN=xwork-2.0.dtd, -//Apache Struts//XWork 1.1//EN=xwork-1.1.dtd, -//Apache Struts//XWork 2.1//EN=xwork-2.1.dtd, -//Apache Software Foundation//DTD Struts Configuration 2.0//EN=struts-2.0.dtd, -//Apache Struts//XWork 2.1.3//EN=xwork-2.1.3.dtd, -//Apache Software Foundation//DTD Struts Configuration 2.3//EN=struts-2.3.dtd, -//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN=struts-2.1.7.dtd, -//Apache Software Foundation//DTD Struts Configuration 2.1//EN=struts-2.1.dtd, -//Apache Struts//XWork 2.3//EN=xwork-2.3.dtd} 
Sep 19, 2015 5:44:13 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider info 
INFO: Parsing configuration file [struts.xml] 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.ObjectFactory) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.factory.ActionFactory) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.factory.ResultFactory) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.factory.ConverterFactory) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.factory.InterceptorFactory) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.factory.ValidatorFactory) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.factory.UnknownHandlerFactory) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.FileManagerFactory) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.XWorkConverter) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.CollectionConverter) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.ArrayConverter) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.DateConverter) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.NumberConverter) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.StringConverter) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ConversionPropertiesProcessor) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ConversionFileProcessor) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ConversionAnnotationProcessor) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.TypeConverterCreator) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.TypeConverterHolder) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.TextProvider) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.LocaleProvider) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.ActionProxyFactory) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ObjectTypeDeterminer) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (org.apache.struts2.dispatcher.mapper.ActionMapper) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (jakarta) for (org.apache.struts2.dispatcher.multipart.MultiPartRequest) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (org.apache.struts2.views.freemarker.FreemarkerManager) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (org.apache.struts2.components.UrlRenderer) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.validator.ActionValidatorManager) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.ValueStackFactory) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.reflection.ReflectionProvider) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.reflection.ReflectionContextFactory) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.PatternMatcher) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (org.apache.struts2.util.ContentTypeMatcher) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (org.apache.struts2.dispatcher.StaticContentLoader) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.UnknownHandlerManager) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (org.apache.struts2.views.util.UrlHelper) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.TextParser) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (org.apache.struts2.dispatcher.DispatcherErrorHandler) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.security.ExcludedPatternsChecker) 
Sep 19, 2015 5:44:13 PM org.apache.struts2.config.AbstractBeanSelectionProvider info 
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.security.AcceptedPatternsChecker) 
Sep 19, 2015 5:44:15 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register 
INFO: Parsing configuration file [struts-default.xml] 
Sep 19, 2015 5:44:15 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register 
INFO: Parsing configuration file [struts-plugin.xml] 
Sep 19, 2015 5:44:15 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register 
INFO: Parsing configuration file [struts.xml] 
Sep 19, 2015 5:44:15 PM org.apache.struts2.config.Settings getLocale 
WARNING: Settings: Could not parse struts.locale setting, substituting default VM locale 
Sep 19, 2015 5:44:16 PM com.opensymphony.xwork2.util.ObjectTypeDeterminerFactory <clinit> 
INFO: Setting DefaultObjectTypeDeterminer as default ... 
Sep 19, 2015 5:44:16 PM org.apache.coyote.AbstractProtocolHandler start 
INFO: Starting ProtocolHandler ["http-bio-8080"] 
Sep 19, 2015 5:44:16 PM org.apache.coyote.AbstractProtocolHandler start 
INFO: Starting ProtocolHandler ["ajp-bio-8009"] 
Sep 19, 2015 5:44:16 PM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 10281 ms 

网络.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"> 
  <welcome-file-list> 
    <welcome-file>index.jsp</welcome-file> 
  </welcome-file-list> 
  <filter> 
    <filter-name>struts2</filter-name> 
    <filter-class> 
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 
    </filter-class> 
  </filter> 
  <filter-mapping> 
    <filter-name>struts2</filter-name> 
    <url-pattern>/*</url-pattern> 
  </filter-mapping> 
 
  <listener> 
  <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class> 
  </listener> 
 
  </web-app> 

struts.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="abc" extends="struts-default"> 
 
<action name="login"> 
<result >login.jsp</result> 
</action> 
 
<action name="loginprocess" class="com.javatpoint.Login"> 
<result name="success"  >loginsuccess.jsp</result> 
<result name="error" >loginerror.jsp</result> 
</action> 
 
<action name="logout" class="com.javatpoint.Login" method="logout"> 
<result name="success" >logoutsuccess.jsp</result> 
</action> 
 
<action name="profile" class="com.javatpoint.Profile"> 
<result name="success" >profilesuccess.jsp</result> 
<result name="error" >profileerror.jsp</result> 
</action> 
 
</package> 
</struts>     

请帮帮我

请您参考如下方法:

org.apache.tiles.listener.TilesListener 仅在 Tiles 2.0.3 中可用

在更高版本的 Tiles 中,监听器类是 org.apache.tiles.web.startup.TilesListener

Download tiles-core-2.0.3.jar


评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!