我的代码与tomcat 7.0和jre 1.7完全一致但是当我尝试使用tomcat 8.0和jre 1.8时,我有错误 我的struts.xml文件
<?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="aa" extends="struts-default">
<action name="">
<result>/login.jsp</result>
</action>
<action name="index">
<result>/login.jsp</result>
</action>
<action name="log" class="com.action.LoginAction" method="execute">
<result name="success">/loginSuccess.jsp</result>
<result name="input">/login.jsp</result>
</action>
<action name="register" class="com.action.RegisterAction" method="execute">
<result name="success">/listAllUser.jsp</result>
</action>
<action name ="reg">
<result>/register.jsp</result>
</action>
</package>
</struts>
&#13;
的login.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:form action="log">
<s:head/>
<s:textfield name="userBean.account" label="Account"></s:textfield>
<s:password name="userBean.passWord" label="Pass word"></s:password>
<s:submit></s:submit>
<p><a href="<s:url action ="reg"></s:url>">you not register?</a></p>
</s:form>
</body>
</html>
&#13;
loginAction.java
package com.action;
import com.model.User;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
private User userBean;
public String execute() throws Exception{
return "success";
}
public User getUserBean() {
return userBean;
}
public void setUserBean(User userBean) {
this.userBean = userBean;
}
public void validate(){
if(userBean.getAccount().length() == 0){
addFieldError("userBean.account", "this account is require");
}
if(userBean.getPassWord().length() == 0){
addFieldError("userBean.passWord", "this pass word is require");
}
}
}
&#13;
和web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Assignment5</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
&#13;
HTTP Status 404 - /Assignment5/
type Status report
message /Assignment5/
description The requested resource is not available.
--------------------------------------------------------------------------------
Apache Tomcat/8.0.28
&#13;
日志文件
Aug 06, 2016 7:16:11 AM org.apache.jasper.servlet.TldScanner scanJars
INFO: 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.
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
ERROR Dispatcher Dispatcher initialization failed
Unable to load configuration. - action - file:/D:/JavaEEProjects/.metadata/.plugins/org.eclipse.wst.server.core/tmp5/wtpwebapps/Assignment5/WEB-INF/classes/struts.xml:19:78
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:897)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:437)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:478)
at org.apache.struts2.dispatcher.InitOperations.initDispatcher(InitOperations.java:75)
at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:63)
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$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: Action class [com.action.registerAction] not found - action - file:/D:/JavaEEProjects/.metadata/.plugins/org.eclipse.wst.server.core/tmp5/wtpwebapps/Assignment5/WEB-INF/classes/struts.xml:19:78
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:493)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:442)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:557)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:311)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:108)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:187)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 17 more
Aug 06, 2016 7:16:12 AM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
Unable to load configuration. - action - file:/D:/JavaEEProjects/.metadata/.plugins/org.eclipse.wst.server.core/tmp5/wtpwebapps/Assignment5/WEB-INF/classes/struts.xml:19:78
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:491)
at org.apache.struts2.dispatcher.InitOperations.initDispatcher(InitOperations.java:75)
at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:63)
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$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: Unable to load configuration. - action - file:/D:/JavaEEProjects/.metadata/.plugins/org.eclipse.wst.server.core/tmp5/wtpwebapps/Assignment5/WEB-INF/classes/struts.xml:19:78
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:897)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:437)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:478)
... 14 more
Caused by: Action class [com.action.registerAction] not found - action - file:/D:/JavaEEProjects/.metadata/.plugins/org.eclipse.wst.server.core/tmp5/wtpwebapps/Assignment5/WEB-INF/classes/struts.xml:19:78
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:493)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:442)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:557)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:311)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:108)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:187)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 17 more
&#13;
我使用struts jar跟随 enter image description here
答案 0 :(得分:-1)
对于Tomcat 8,您需要将以下行添加到tomcat/conf/logging.properties
,以便Tomcat扫描的jar文件显示在日志中:
org.apache.jasper.servlet.TldScanner.level = FINE
将此行添加到{CATALINA-HOME}/conf/logging.properties
的末尾:
org.apache.jasper.level = FINEST
关闭服务器(如果已启动)。
打开控制台并运行(如果是Windows):
%CATALINA_HOME%\bin\catalina.bat run
享受日志,例如(再次,对于Windows):
{CATALINA-HOME}/logs/catalina.2015-12-28.log