Struts2学习 路径访问
来源:互联网 发布:淘宝上面的挪威三文鱼 编辑:程序博客网 时间:2024/05/18 00:50
一般访问某个jsp程序如下,假设index.jsp在WebContent里面
<a href="index.jsp">
若不使用structs框架,则可以访问到,但是使用了该框架,就不能这么访问了
首先structs Action 访问举个例子,在浏览器输入http://localhost:8080/project-name/packge-namespace/action-name,若是我在该链接里的某个jsp页面里 访问另一个jsp
<a href="index.jsp">
则访问路径为:http://localhost:8080/project/name/packge-namespace/index.jsp, 两个jsp访问的package-namespace是一样的,但是是访问不到index.jsp的,这说明
structs框架的路径访问 不是根据资源的位置路径来访问,而是根据Action的路径来访问,因此
Structs 路径访问资源,一定要采用绝对路径访问,最后的访问路径应该类似这样:http://localhost:8080/project-name/index.jsp
贴出一段路径访问demo
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Index.jsp</title></head><base href="<%=basePath%>"><body>index index index index index index aaaaa<a href="Hello.jsp">路径问题说明</a></body></html>期中,调用
<base href="<%=basePath%>">可使得整个页面的所有路径自动加上basePath(basePath为http://localhost:8080/project-name),最后的访问路径类似这样:http://localhost:8080/project-name/index.jsp
0 0
- Struts2学习 路径访问
- Struts2学习笔记三——Namespace与访问路径
- Struts2 Action的访问路径
- Struts2 Action的访问路径
- Struts2的访问路径一:固定访问路径
- Struts2中action访问路径配置
- struts2整合CXF访问路径冲突问题
- Struts2学习之路径问题
- Struts2学习(二)【Struts2访问流程】
- Struts2的访问路径二:使用通配符配置访问路径一
- Struts2的访问路径三:使用通配符配置访问路径二
- Struts2的访问路径四:使用动态路径访问(不推荐使用)
- 获取上当前访问路径问题 (struts2)
- struts2零配置(注解)的访问路径
- Tomcat Server + Struts2 + Spring,web工程的访问路径
- struts2命名空间namespace和访问路径的关系
- Struts2框架修改访问路径后缀的三种方式
- struts2命名空间namespace和访问路径的关系
- linux 新加用户和密码
- Android源码编译
- How can I set default terminal used in Unity?
- 交互shell设置为/dev/console之后提示job control turned off(下)
- Python - reload(sys) + sys.setdefaultencoding
- Struts2学习 路径访问
- PHP防CC攻击防止快速刷新代码
- JS验证输入框只能输入数字,并且只能含有2位小数
- 容器query与list
- Java并发的四种风味:Thread、Executor、ForkJoin和Actor
- Linux虚拟内存管理(glibc) mmap sbrk
- 获取当前jar包的绝对路径
- Hadoop常见问题及解决办法
- 手把手教你高仿微信6.0ActionBa