我有一个基于html:form操作的jsp。
<html:form action="/nextPath">
我想根据变量或当前路径设置操作.....
<d:isActionPath path="/path1" >
<html:form action="/nextPath1">
</d:isActionPath>
<d:isActionPath path="/path2" >
<html:form action="/nextPath2">
</d:isActionPath>
这行不通。但这本质上是我想做的。
有什么建议吗?对支柱非常陌生。
<d:isActionPath path="/path1" >
<c:set var="theAction" value="/nextPath1"/>
</d:isActionPath>
<d:isActionPath path="/path2" >
<c:set var="theAction" value="/nextPath2"/>
</d:isActionPath>
<html:form action="${theAction}">
...
</html:form>
JSP 标记必须正确平衡,就像在 XML 文档中一样。您无法打开标签d:isActionPath
,打开标签html:form
并在未关闭html:form
标签的情况下关闭d:isActionPath
标签。
我遇到了类似的问题:
无法检索操作/${theAction} 的映射
我将 ${theAction} 替换为 <%= theAction %>,它对我有用(支柱 1.2.9、J2SE-1.5 和 jboss-4.2.3.GA)。
因此,您可以尝试以下操作:
<% String theAction = "/nextPath"; %>
<d:isActionPath path="/path1" >
<% theAction = "/nextPath1"; %>
</d:isActionPath>
<d:isActionPath path="/path2" >
<% theAction = "/nextPath2"; %>
</d:isActionPath>
<html:form action="<%= theAction %>">
...
</html:form>
编辑:实际上我很困惑,为什么它使用 <%= %> 表示法?是因为 html 标记没有正确解释吗?