在Struts2中的s:form,为啥我将theme设为ajax会报错?项目中也有freemarker.jar包啊
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Struts2中的s:form,为啥我将theme设为ajax会报错?项目中也有freemarker.jar包啊相关的知识,希望对你有一定的参考价值。
<s:form action="" theme="ajax" validate="true">
<s:textfield label="姓名" name="name"/>
</s:form>
报:org.apache.jasper.JasperException: Expression parameters.parseContent is undefined on line 45, column 28 in template/ajax/head.ftl. - Class: freemarker.core.TemplateObject
File: TemplateObject.java
Method: assertNonNull
头部你还了吗追问
头部也设了啊
追答on line 45, column 28 in template/ajax/head.ftl. - Class: freemarker.core.TemplateObject
你看看45行的代码是不是有问题啊。
HTTP状态500 - 在Struts2应用程序中处理JSP页面时发生异常
我正在学习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
不见了。
见how to create a maven project。
以上是关于在Struts2中的s:form,为啥我将theme设为ajax会报错?项目中也有freemarker.jar包啊的主要内容,如果未能解决你的问题,请参考以下文章
Struts2中的json 注解@deserialize为啥没用?