Java 如何使用JSTLC:选择更改表单操作
我的jsp页面上有一个表单操作,我希望该操作根据被操纵的“用户”的不同而改变Java 如何使用JSTLC:选择更改表单操作,java,jsp,jstl,Java,Jsp,Jstl,我的jsp页面上有一个表单操作,我希望该操作根据被操纵的“用户”的不同而改变 <c:choose> <c:when test="${user.user_username==username}"> <form method="post" action="myinfo" class="form-horizontal"> </c:when> <c:otherwise>
<c:choose>
<c:when test="${user.user_username==username}">
<form method="post" action="myinfo" class="form-horizontal">
</c:when>
<c:otherwise>
<form method="post" action="updated" class="form-horizontal">
</c:otherwise>
</c:choose>
我在页面底部有一个提交按钮。根据被操纵的用户,我想将页面重定向到“myinfo”或“updated”。然而,我不断收到一个错误,说表单没有结束标记。我在最底部将其关闭,但我想这不是正确的方法。使用
将操作设置为变量,然后在表单中使用它
<c:choose>
<c:when test="${user.user_username==username}">
<c:set var="formAction" value="myinfo" />
</c:when>
<c:otherwise>
<c:set var="formAction" value="updated" />
</c:otherwise>
</c:choose>
<form method="post" action="${formAction}" class="form-horizontal">
...
</form>
...
使用
将操作设置为变量,然后在表单中使用它
<c:choose>
<c:when test="${user.user_username==username}">
<c:set var="formAction" value="myinfo" />
</c:when>
<c:otherwise>
<c:set var="formAction" value="updated" />
</c:otherwise>
</c:choose>
<form method="post" action="${formAction}" class="form-horizontal">
...
</form>
...
啊,太酷了。我不知道这是可能的。谢谢我想+1你,但我还没有足够的分数,呵呵,太酷了。我不知道这是可能的。谢谢我想+1你,但我还没有足够的分数,呵呵