contextRelative是用来设置当前path路径的为“true”为当前根路径

来源:互联网 发布:java web 开发ide 编辑:程序博客网 时间:2024/06/06 15:04

http://blog.sina.com.cn/s/blog_65dcacbb0100hw9j.html


原文地址:struts中的redirect,contextRelative作者:fumin

转自:http://hi.baidu.com/nickshen3/blog/item/53d6df2a2180a22ed52af168.html


1.redirect    设为true时表示执行重定向操作;当为false时,表示执行请求转发操作   
     注        重定向操作一般用命令:response.sendRedirect();   
               请求转发操作      RequestDispatcher    rpath=request.getRequestDispatcher();   
                                             rpath.forward(request,response);   
                                         jsp中:<jsp:forward    page="">   
   这两个操作的区别请楼主自己查阅资料或到csdn搜索相关主题   
    
   2.contextRelative      设为true时表示当前path属性以/开头时,给出的是相对于当前上下文的url。默认为false

================================================

1,redirect设置响应返回类型,redirect="true":重定向    缺省值为redirect="false":转发

2,如果当前路径为http://localhost/moduleA/   
   <forward    name="..."    path="/target.jsp"    redirect="true"    contextRelative="false"/>     
   执行以上forward时会转向http://localhost/moduleA/target.jsp   
   如contextRelative="true"时,会转向http://localhost/target.jsp   
   在struts1.1以上,通常使用module="/moduleA"代替   


0 0
原创粉丝点击