当前位置: 代码迷 >> Web前端 >> response.sendredirect的适用用法
  详细解决方案

response.sendredirect的适用用法

热度:101   发布时间:2012-09-20 09:36:50.0
response.sendredirect的实用用法

通过localhost:8080/cms进入后台管理系统的登录界面,在web.xml中配置如下

?<welcome-file-list>
? <welcome-file>/index.jsp</welcome-file>
?</welcome-file-list>

?

由于界面全部采用的是freemarker模板的ftl格式,需要通过一个action来跳转到login.ftl,action中的配置如下:

?

??? ??? <action name="login*"
??? ??? ? class="b2cLoginAction" >
??? ??? ??? <result name="input" type="freemarker">/WEB-INF/pages/b2c/login.ftl</result>
??? ??? ??? <result name="success" type="redirect">/myCenter.html</result>
??? ??? ??? <interceptor-ref name ="myStack"/>??? ???
??? ??? </action>

现在我们怎么让在游览器中输入 localhost:8080/cms就能直接进入login.ftl界面呢?

方法如下:

使用url重写的方法,编辑 urlrewrite.xml,配置如下:

?<urlrewrite>
???
??? <rule>
??? ??? <from>^/index.html</from>
??? ??? <to>/b2c/login.action</to>
??? </rule>

?

在index.jsp中配置如下:

?

<%@ page language="java" contentType="text/html; charset=utf-8"
??? pageEncoding="utf-8"%>
<%
response.sendRedirect ( "index.html");
%>

  相关解决方案