如何根据按下的表单的提交按钮将用户重定向到不同的页面:
URL 重定向是一种万维网技术,用于使网页在多个URL address 下可用。当 Web 浏览器尝试打开已重定向的 URL 时,会打开具有不同 URL 的页面。
For example, www.example.com is redirected to example.iana.org.
同样,Domain redirection 或 domain forwarding 是 URL 域中的所有页面都被重定向到不同的域时,就像 wikipedia.com 和 wikipedia.net 被自动重定向到 wikipedia.org 时一样。
URL 重定向可用于 URL 缩短、防止网页移动时断开链接、允许属于同一所有者的 multiple domain 名称引用单个网站、引导导航进出网站,用于隐私保护和网络钓鱼攻击等不太无害的目的。
<form action="http://example.org/ jmail1.java">
<input type="submit" value="Go To jmail1.java">
</form>
<form action="http://example.org/jmail2.java">
<input type="submit" value="Go To jmail2.java">
</form>
技术:
Several different kinds of response to the browser will result in a redirection.
These vary in whether they affect HTTP headers or HTML content. The techniques used typically depend on the role of the person implementing it and their access to different parts of the system.
例如,无法控制标题的网络作者可能会使用刷新元标记,而重定向站点上所有页面的网络服务器管理员更可能使用服务器配置。
<action name="foo">
<result type="redirectAction">
<param name="actionName">bar</param>
<param name="namespace">/</param>
</result>
</action>
虽然信息路径使您能够在提交后创建自定义消息,但许多用户的要求不止于此。他们对表格让您坐在列表中的方式不满意,这可能会令人困惑。因此,我们有一种方法可以让 InfoPath 表单的功能类似于传统的 Web 表单,您可以在其中填写表单,然后单击“提交”按钮,将用户带到感谢页面
分辨率:
创建感谢页面并将其保存在您网站的某个位置。我们建议使用任何编辑器(例如记事本或 SharePoint Designer)创建一个带有您选择的消息的 html 页面,例如“感谢您的提交”
单击该感谢页面并记录 URL I.E.,它将如下所示:http://mydomain.com/sites/YourSite/YourDocLibrary/ThankYou.html
现在您需要找出 InfoPath 表单的 URL。单击它并记录 URL,或者如果您已将 InfoPath 表单附加到 SharePoint 列表,那么您将需要像这样更改 URL:http://mydomain.com/sites/YourSite/YourList/NewForm.aspx,您可以看到我们刚刚将 NewForm.aspx 添加到末尾。
Take the URL you recorded in step 3 and add the following:? Source=http://mydomain.com/sites/YourSite/YourDocLibrary/ThankYou.html,因此 URL 应如下所示:http://mydomain.com/sites/YourSite/YourList/NewForm.aspx?Source=http://mydomain.com/sites/YourSite/YourDocLibrary/ThankYou.html
在感谢页面上,您可以添加一个链接以转到另一个页面,或者您可以真正花哨并添加一个元刷新标签以自动将您的用户重定向到您网站的主页.你是怎样做的?简单的。在 HTML 页面的标签之间添加这一行:<meta http-equiv="refresh" content="2;url=http://mydomain.com/sites/yourSite/">。只是为了多解释一下那条线,在这种情况下,数字 2 代表 2 秒。因此,您可以通过用不同的数字替换该数字来修改它,以使用户在该页面上的时间更长或更短。该网址将是您的主页或您要将用户重定向到的任何其他网站的网址。
<table><tr>
<td><s:submit name="update" value="Update" action="update" ></s:submit></td>
<td><s:submit name="delete" value="Delete" action="delete" ></s:submit></td>
</tr></table>
<action name="update"
class="net.viralpatel.struts2.action.MemberCrudOpertaions"
method="updateUser">
<result>members.jsp</result>
</action>
<action name="delete"
class="net.viralpatel.struts2.action.MemberCrudOpertaions"
method="deleteUser">
<result>members.jsp</result>
</action>`
手动重定向:
最简单的技术是让访问者点击一个指向新页面的链接,通常使用如下 HTML 锚点:
Please follow <a href="http://www.example.com/">this link</a>.
此方法通常用作后备——如果浏览器不支持自动重定向,访问者仍然可以通过链接到达目标文档。
默认重定向:
默认重定向技术是要求访问者点击指向新页面的链接,通常使用带有 JSP 的 HTML,例如:
<html>
<%
String redirectURL = "http://stackoverflow.com/";
response.sendRedirect(redirectURL);
%>
</html>
http://struts.apache.org/release/2.2.x/docs/redirect-action-result.html
http://struts.apache.org/development/2.x/docs/multiple-submit-buttons.html
http://struts.apache.org/development/2.x/docs/submit.html
http://struts.apache.org/release/2.2.x/docs/interceptors.html
相关来源:http://en.wikipedia.org/