Jsp 我们如何将一个域的所有请求重定向到另一个域的某个部分?
我们有两个域,Jsp 我们如何将一个域的所有请求重定向到另一个域的某个部分?,jsp,url,redirect,Jsp,Url,Redirect,我们有两个域,example.com和example.net。我们希望对example.net的每个请求都重定向到example.com/example\u section/index.jsp。如何实现这一点?在服务器上的.htaccess文件中 Redirect permanent http://www.example.net/index.jsp http://www.example.com/example_section/index.jsp. 或者您可以在http://www.exampl
example.com
和example.net
。我们希望对example.net
的每个请求都重定向到example.com/example\u section/index.jsp
。如何实现这一点?在服务器上的.htaccess文件中
Redirect permanent http://www.example.net/index.jsp http://www.example.com/example_section/index.jsp.
或者您可以在http://www.example.net/index.jsp
翻页并添加
<%
String redirectURL = "http://www.example.com/example_section/index.jsp";
response.sendRedirect(redirectURL);
%>
或者你可以在同一页上写
<jsp: forward page="http://www.example.com/example_section/index.jsp"/>
这将转发页面。请提供更多详细信息。如果只是重定向,只需通过onclick事件在js中执行即可。onclick='window.location.href=”“'就像您可以使用的那样。
.htaccess
文件只有在您的servletcontainer前面有Apache HTTPD时才有效(因为.htaccess
文件是特定于Apache HTTPD的,在Tomcat上不起作用等等)。scriptlet方式将起作用,但首选的方式是过滤器like。jsp:forward
完全是服务器端的,不会反映浏览器地址栏中的URL更改。