当前位置: 首页 > 知识库问答 >
问题:

使用tomcat 8 jre 1.8时struts 2出现错误

潘宸
2023-03-14

我的代码完全使用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>

登录。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>

登录。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");
		}
	}
}

还有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>
HTTP Status 404 - /Assignment5/
type Status report

message /Assignment5/

description The requested resource is not available.


--------------------------------------------------------------------------------

Apache Tomcat/8.0.28

日志文件

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

我使用struts jar在这里输入图像描述

共有1个答案

弓俊晖
2023-03-14

对于Tomcat 8,您需要将以下行添加到tomcat/conf/logging.properties中,以便Tomcat扫描的罐显示在日志中:

org.apache.jasper.servlet.TldScanner.level = FINE

>

  • 将此行添加到{CATALINA-HOME}/conf/logging.properties的末尾:org.apache.jasper.level=FINEST

    关闭服务器(如果已启动)。

    打开控制台并运行(在Windows的情况下):

    享受日志,例如(同样适用于Windows):

    {CATALINA-HOME}/logs/CATALINA。2015-12-28.日志

  •  类似资料:
    • 我尽了最大努力,但没有成功。< code >索引操作加载正常,但当我导航到test时,生成了错误。不知道为什么会这样。 磅.xml struts.xml 平铺.xml 错误 项目结构

    • 它需要做的是获取用户名和密码,验证它并根据密码给出适当的输出。请帮帮我.也让我知道如果我的怀疑是正确的。另外,我听说在servlet程序中编写html代码不是一个好的做法。我还想知道如何在index.html文件中编写上面的html代码,这应该与该程序预期的行为方式相同。谢了。

    • 大约一到两周前,我就无法使用pip,因为它总是会回退以下错误: 错误:由于环境原因无法安装程序包错误:HTTPSConnectionPool(host='files.pythonhosted.org',port=443):url超过最大重试次数:/packages/1b/e5/552ba6583ab43e12b299458fea94ee23886125b8b8babc91edb03f2ba65/p

    • 编译以下使用Lombok自动生成getter和setter的类时,Checkstyle引发编译错误: 实用工具类不应具有公共或默认构造函数 当Checkstyle没有按照Checkstyle文档中指定的实用程序类定义时,为什么Checkstyle将上面的类归类为实用程序类?即只包含静态方法或字段的类。checkstyle解析的是默认源文本文件还是lombok生成的源文件?

    • 下面是用eclipse IDE编写的Java代码... 线程“main”java.lang.NullPointerException在compile.execute.main(execute.java:17)中出现异常 你能告诉我如何解决这个错误吗?

    • 我正在构建我的第一个struts2应用程序,并得到错误: HTTP状态404-/Struts2Beginner/Input。jsp 输入状态报告-message/Struts2Beginner/Input。jsp说明请求的资源不可用 ApacheTomcat/7.0.64 关于这个问题有很多帖子,我想我消除了两个常见问题: 我正在使用StrutsPrepareAndExecuteFilter(而不

    • 我的ThymileAF模板中有一个AngularJS属性,看起来像这样: 当Thymeleaf尝试处理此模板时,我得到以下异常: Thymeleaf只是不能很好地处理

    • 我想摆脱这个错误。我读到一个类似的问题,其中一个答案建议我可以使用以下命令禁用验证: 我的确切错误是: 在C:\ path \ guzzle \ src \ Handler \ cURL factory . PHP:187堆栈跟踪:# 0 C:\ path \ guzzle \ src \ Handler \ cURL factory . PHP:187堆栈跟踪:# 0 C:\ path \ gu