struts2 formName is undefined

使用doubleselect 出现下错误:

 exception

org.apache.jasper.JasperException
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:476)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)
	org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)

 

root cause

Expression parameters.formName is undefined on line 101, column 43 in template/simple/doubleselect.ftl. - Class: freemarker.core.TemplateObject
File: TemplateObject.java
Method: assertNonNull
Line: 124 - freemarker/core/TemplateObject.java:124:-1
	org.apache.struts2.components.UIBean.end(UIBean.java:515)
	org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
	org.apache.jsp.doubleselect_jsp._jspx_meth_s_005fdoubleselect_005f0(doubleselect_jsp.java:185)
	org.apache.jsp.doubleselect_jsp._jspx_meth_s_005fform_005f0(doubleselect_jsp.java:133)
	org.apache.jsp.doubleselect_jsp._jspService(doubleselect_jsp.java:76)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)
	org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)

 

root cause

freemarker.core.InvalidReferenceException: Expression parameters.formName is undefined on line 101, column 43 in template/simple/doubleselect.ftl.
	freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
	freemarker.core.Expression.getStringValue(Expression.java:118)
	freemarker.core.Expression.getStringValue(Expression.java:93)
	freemarker.core.DollarVariable.accept(DollarVariable.java:76)
	freemarker.core.Environment.visit(Environment.java:208)
	freemarker.core.MixedContent.accept(MixedContent.java:92)
	freemarker.core.Environment.visit(Environment.java:208)
	freemarker.core.Environment.include(Environment.java:1477)
	freemarker.core.Include.accept(Include.java:169)
	freemarker.core.Environment.visit(Environment.java:208)
	freemarker.core.MixedContent.accept(MixedContent.java:92)
	freemarker.core.Environment.visit(Environment.java:208)
	freemarker.core.Environment.process(Environment.java:188)
	freemarker.template.Template.process(Template.java:237)
	org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:182)
	org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:559)
	org.apache.struts2.components.UIBean.end(UIBean.java:513)
	org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
	org.apache.jsp.doubleselect_jsp._jspx_meth_s_005fdoubleselect_005f0(doubleselect_jsp.java:185)
	org.apache.jsp.doubleselect_jsp._jspx_meth_s_005fform_005f0(doubleselect_jsp.java:133)
	org.apache.jsp.doubleselect_jsp._jspService(doubleselect_jsp.java:76)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)
	org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)

 

方法一:需要指定formName ,给form起个名字 ,如<s:form action="Store" name="form0" >,

doubleselect默认找到这个form0。

 

方法二:指定formName ,给form起个名字的同时再doubleselect中指定其formName=“form0

你可能感兴趣的:(java,apache,jsp,freemarker,servlet)