gpt4 book ai didi

java - HTTP 状态 500 - Struts2 应用程序中处理 JSP 页面时发生异常

转载 作者:太空宇宙 更新时间:2023-11-04 15:19:36 24 4
gpt4 key购买 nike

我正在学习 Struts2,并在托管我的应用程序时遇到以下问题。index.jsp页面,具有/struts-tags 示例 <s:form>, <s:url>等,在托管应用程序时抛出异常。

项目中使用的 jar :

common-lang3.jar
commons-fileupload-1.3.jar
commons-io-2.0.1.jar
commons-logging-1.1.3.jar
commons-logging-api-1.1.jar
freemarker-2.3.19.jar
javassist-3.11.0.GA.jar
ognl-3.0.6.jar
struts2-core-2.3.15.3.jar
xwork-core-2.3.15.3.jar

异常堆栈跟踪:

    **HTTP Status 500 - An exception occurred processing JSP page /index.jsp at line 12**
**type** Exception report
**message** An exception occurred processing JSP page /index.jsp at line 12

**description** The server encountered an internal error that prevented it from fulfilling this request.

**exception**
org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 12

9: </head>
10:
11: <body>
12: <s:form action="empinfo" method="post">
13: <s:textfield name="name" label="Name" size="20" />
14: <s:textfield name="age" label="Age" size="20" />
15: <s:submit name="submit" label="Submit" align="center" />


Stacktrace:

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:412)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)

**root cause**
javax.servlet.ServletException: java.lang.NoSuchMethodError: org.apache.commons.lang3.StringUtils.containsIgnoreCase(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Z
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
org.apache.jsp.index_jsp._jspService(index_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)

**root cause**
java.lang.NoSuchMethodError: org.apache.commons.lang3.StringUtils.containsIgnoreCase(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Z
org.apache.struts2.views.util.DefaultUrlHelper.buildUrl(DefaultUrlHelper.java:180)
org.apache.struts2.views.util.DefaultUrlHelper.buildUrl(DefaultUrlHelper.java:75)
org.apache.struts2.views.util.DefaultUrlHelper.buildUrl(DefaultUrlHelper.java:70)
org.apache.struts2.components.ServletUrlRenderer.renderFormUrl(ServletUrlRenderer.java:200)
org.apache.struts2.components.Form.populateComponentHtmlId(Form.java:231)
org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:801)
org.apache.struts2.components.ClosingUIBean.start(ClosingUIBean.java:55)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:53)
org.apache.jsp.index_jsp._jspx_meth_s_005fform_005f0(index_jsp.java:104)
org.apache.jsp.index_jsp._jspService(index_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)

<强> index.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>
<title>Employee Form</title>
</head>

<body>
<s:form action="empinfo" method="post">
<s:textfield name="name" label="Name" size="20" />
<s:textfield name="age" label="Age" size="20" />
<s:submit name="submit" label="Submit" align="center" />
</s:form>
</body>
</html>

<强> struts.xml :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="helloworld" extends="struts-default">
<action name="empInfo" class="com.tutorialspoint.struts2.EmployeeAction" method="execute">
<result name="input">/index.jsp</result>
<result name="success">/success.jsp</result>
</action>
</package>
</struts>

<强> web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>HelloWorldStruts2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<!--<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>-->
<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>
</web-app>

请建议我如何解决此问题。

最佳答案

您的项目中似乎部署了不完整的库 jar。尝试从 Maven 存储库下载所需的 jar 或在 struts 发行版 lib 文件夹中查找它们。

commons-lang3-3.1.jar

缺失。

参见how to create a maven project .

关于java - HTTP 状态 500 - Struts2 应用程序中处理 JSP 页面时发生异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20545369/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com