Using Struts 2.1.8
I am having a problem inserting an attribute from the session into the
value of a struts2 submit tag. I am trying to convert some struts1 tags
to struts2. I converted the form tag to struts2 and can use a struts1
submit tag inside the struts2 form. The struts1 submit tag uses an
attribute from the session. However, when I try to insert an attribute
from the session into the value attribute of the struts2 submit tag it
doesn't work. The value of the session attribute
SALES_RATES_SERVICE_TYPE is "Test".
Tag Libraries:
<%@ taglib uri="/WEB-INF/struts-bean" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic" prefix="logic" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
Struts1 tags only - works
<html:form action="/sales_rates_get_status">
<html:submit styleClass="button" >Get <bean:write
name="SALES_RATES_SERVICE_TYPE" /> Rates</html:submit>
</html:form>
Mixture of Struts2 and Struts1 tags - works
<s:form action="sales_rates_get_status">
<html:submit styleClass="button" >Get <bean:write
name="SALES_RATES_SERVICE_TYPE" /> Rates</html:submit>
</s:form>
Struts2 tags only - doesn't work
<s:form action="sales_rates_get_status">
<s:submit value="%{'<s:property
value="#session.SALES_RATES_SERVICE_TYPE"/>'}"/>
</s:form>
Error:
com.ibm.ws.jsp.JspCoreException:
/pages/sales_rates/sales_rates_kickoff.jsp(10,80) JSPG0055E:
Unable to create an xml attribute from name
[#session.SALES_RATES_SERVICE_TYPE] value [/>'}]
at
com.ibm.ws.jsp.translator.document.Jsp2Dom.getJspDocumentAsJspPage(Jsp2D
om.java:300)
at
com.ibm.ws.jsp.translator.document.Jsp2Dom.getJspDocument(Jsp2Dom.java:1
79)
at com.ibm.ws.jsp.translator.JspTranslator.<init>(JspTranslator.java:73)
at
com.ibm.ws.jsp.translator.JspTranslatorFactory.createTranslator(JspTrans
latorFactory.java:116)
at
com.ibm.ws.jsp.translator.utils.JspTranslatorUtil.translateJsp(JspTransl
atorUtil.java:229)
at
com.ibm.ws.jsp.translator.utils.JspTranslatorUtil.translateJspAndCompile
(JspTranslatorUtil.java:114)
at
com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.transl
ateJsp(AbstractJSPExtensionServletWrapper.java:501)
at
com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper._check
ForTranslation(AbstractJSPExtensionServletWrapper.java:428)
at
com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.checkF
orTranslation(AbstractJSPExtensionServletWrapper.java:290)
at
com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handle
Request(AbstractJSPExtensionServletWrapper.java:145)
at
com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.handleReque
st(AbstractJSPExtensionProcessor.java:286)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppReq
uestDispatcher.java:639)
at
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.ja
va:1042)
at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:4
88)
at
org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequ
estContext.java:103)
at
org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesReq
uestContext.java:96)
at
org.apache.tiles.renderer.impl.UntypedAttributeRenderer.write(UntypedAtt
ributeRenderer.java:61)
at
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(Abst
ractBaseAttributeRenderer.java:103)
at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.jav
a:669)
etc.
David Smith