c:redirect的用法
时间:2010-08-24
来源:互联网
web.xml:
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
<welcome-file>/index.html</welcome-file>
</welcome-file-list>
webRoot下的index.jsp:
<%@page contentType="text/html; charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<c:redirect url="/login/"/>
webRoot的目录结构:
|----webRoot
|-----login
|---------login.jsp
|---------index.jsp
|-----index.jsp
为什么跳转到的页面是login目录下的index.jsp而不是login.jsp,c:redirect标签用的不是很熟,望知情兄点拨一二,不胜感激,拜谢!
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
<welcome-file>/index.html</welcome-file>
</welcome-file-list>
webRoot下的index.jsp:
<%@page contentType="text/html; charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<c:redirect url="/login/"/>
webRoot的目录结构:
|----webRoot
|-----login
|---------login.jsp
|---------index.jsp
|-----index.jsp
为什么跳转到的页面是login目录下的index.jsp而不是login.jsp,c:redirect标签用的不是很熟,望知情兄点拨一二,不胜感激,拜谢!
作者: shen8 发布时间: 2010-08-24
第一个 代码运行的方式是由上而下的 那么在web.xml中代码首先运行到
<welcome-file>/index.jsp</welcome-file>
如果找到,就会显示index.jsp,如果没找到index.jsp就会继续运行到
<welcome-file>/index.html</welcome-file>即显示index.html,至于两个都没找到会怎样,呵呵,你自己去试试吧
第二个 当用户没有指定访问某个目录上的哪个页面时,就会默认访问index.jsp或者index.html
第三个 c:redirect是把用户请求重定向的标签,你那<c:redirect url="/login/"/>是把目录重定向到login目录里面去了,又由于上面第二个原因,所以就导航到login/index.jsp里面去了
你可以试试改成<c:redirect url="/login/login.jsp"/>看是否显示login里的login.jsp就知道了
呵呵,不知道我说的对不对
<welcome-file>/index.jsp</welcome-file>
如果找到,就会显示index.jsp,如果没找到index.jsp就会继续运行到
<welcome-file>/index.html</welcome-file>即显示index.html,至于两个都没找到会怎样,呵呵,你自己去试试吧
第二个 当用户没有指定访问某个目录上的哪个页面时,就会默认访问index.jsp或者index.html
第三个 c:redirect是把用户请求重定向的标签,你那<c:redirect url="/login/"/>是把目录重定向到login目录里面去了,又由于上面第二个原因,所以就导航到login/index.jsp里面去了
你可以试试改成<c:redirect url="/login/login.jsp"/>看是否显示login里的login.jsp就知道了
呵呵,不知道我说的对不对
作者: goden2009 发布时间: 2011-10-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28