如何使用url重写概念? [英] How to use url rewriting concept?
问题描述
如何在下面的代码中使用<s:Form action="delete">
中的URL重写
如何解决此错误
How to use URL rewriting in <s:Form action="delete">
in this below code
how to resolve this error
<s:iterator value="masterlist" var="item">
<tr bordercolor="#E6E6E6">
<td><a href="<s:url namespace="" action="uncchequepopulate1">
<s:param name="chequeNumber" value="%{#item.chequeNo}" /></s:url>">
<s:property value="%{#item.doncd}" />
</a>
</td>
<td><s:property value="%{#item.dondesc}" /> </td>
<td><s:property value="%{#item.dondesce}" /></td>
<td><s:property value="%{#item.accno}" /></td>
<center> <td>
<s:form action="delete?doncod=<s:property value="%{#item.doncd}" />" >
<s:submit value="Delete" theme="simple"></s:submit></s:form></td><center>
<center> <td> <s:form action="modify" name="regform" id="formSelectOne" theme="simple">
<s:submit value="MODIFY" theme="simple"></s:submit></s:form></td> </center>
</s:iterator>
如何解决此错误
HTTP Status 500 - /Masterindex.jsp (line: 116, column: 60) Unterminated `<s:form>` tag this error will be display how to resolve
推荐答案
在将带有表单标记的s:url
标记与参数一起使用之前,可以构建URL. s:form
标记使用action
属性来映射动作,但是如果它们的格式正确,它也会接受URL.那就是我们现在要做的.
You can build the URL with the s:url
tag with parameters before you use it with the form tag. The s:form
tag uses the action
attribute to map with the action but it also accept URLs if they are properly formatted. That what we will do now.
<s:url var="deleteUrl" action="delete" includeContext="false"><s:param name="doncod" value="%{#item.doncd}"/></s:url>
<s:form action="%{#deleteUrl.substring(1)}" method="POST">
另一种方法,最推荐的方法是使用hidden
字段作为请求参数来保存与表单一起提交的值.
Another approach, which most recommended is to use hidden
field as request parameter to hold the value submitted with the form.
<s:form action="delete" method="POST">
<s:hidden name="doncod" value="%{#item.doncd}"/>
因此,这两种方法都可以用于传递带有表单操作的参数.
So, these two methods could be used to pass a parameter with the form action.
这篇关于如何使用url重写概念?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!