servlet访问路径测试(path)
来源:互联网 发布:高仿阿迪达斯淘宝店 编辑:程序博客网 时间:2024/06/15 19:39
1、getContextPath:站点名[/context](Web应用的入口点名字)
2、getServletPath:servlet类的对应映射路径[/resource]
3、getRequestURI:uri地址 = [/context] + [/resource]
4、getRequestURL:protocol://IP adderss:[port][/context][/resource][/?query string]
5、代码显例如下:
package com.tiger.path.action;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.*;/** * 结论:在jsp的标签中写入下面一段代码,之后所有链接都可以使用绝对路劲,像这样 *" /> * 测试访问路径,测试输出结果如下: * ContextPath = /Struts_0040_Path * ServeltPath = /path.do * RquestURI = /Struts_0040_Path/path.do * RquestURL = http://localhost:8080/Struts_0040_Path/path.do * Scheme = http * ServerName = localhost * ServerPort = 8080 * @author tiger * @time 2017年9月7日 */@WebServlet("/path.do")public class Path extends HttpServlet {private static final long serialVersionUID = 1L; public Path() { }protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {PrintWriter out = response.getWriter();out.append(" ContextPath = ").append(request.getContextPath()).append("
");}}
").append(" ServeltPath = ").append(request.getServletPath()).append("
").append(" RquestURI = ").append(request.getRequestURI()).append("
").append(" RquestURL = ").append(request.getRequestURL()).append("
").append(" Scheme = ").append(request.getScheme()).append("
").append(" ServerName = ").append(request.getServerName()).append("
").append(" ServerPort = ").append(String.valueOf(request.getServerPort())+"
阅读全文
1 0
- servlet访问路径测试(path)
- Servlet访问路径
- servlet路径访问问题
- tomcat 设置path 访问路径
- Servlet 的路径访问问题
- Servlet中访问资源路径
- C# 文件路径 Path类 测试
- web.xml servlet 路径配置与ajax 访问路径
- servlet path
- c# Directory.Delete(path, true) 路径不允许访问
- 关于Servlet中getServletContext() 的getResourceAsStream(String path) 方法中的path路径问题
- PATH路径
- Path路径
- 路径path
- 多路径(multi-path)安装测试实例
- Spring对访问路径进行配置(spring-servlet.xml)
- tomact访问servlet的相关配置和文件存放路径
- Servlet和jsp对外访问路径的配置的…
- android Notifaction学习笔记
- JAVA 的ASCII字符编码一览表
- 2017 年 8 月:15 个有趣的 JS 和 CSS 库
- iOS之《Effective Objective-C 2.0》读书笔记(41)
- Build an IRC Server with Ircd Hybrid and Anope on Ubuntu 14.04
- servlet访问路径测试(path)
- 自己实现智能指针
- 检测文件mime类型和模糊哈希
- 一张图学会git命令
- codeforces433DIV2.(Sep 7th 2017)
- 关于epoll版服务器的理解(Python实现)
- 服务器增强版(TCP)
- 面试之STAR法则
- XML配置文件导入dtd文件仍然没有自动提示问题的解决