我正在学习Struts2并在托管我的应用程序时面临以下问题。 index.jsp
页面,有/ struts-tags示例<s:form>, <s:url>
等,在托管应用程序时抛出异常。
项目中使用的罐子:
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 distro lib
文件夹中查找它们。
commons-lang3-3.1.jar
不见了。