关于Servlet开发中的目录
来源:互联网 发布:淘宝县级运营中心加盟 编辑:程序博客网 时间:2024/05/18 20:51
最近再用Servlet,但是被各种目录搞得七荤八素,然后用下面的代码理顺了:)
public static void show(HttpServlet servlet,HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{System.out.println("*************** REQUEST PATH");System.out.println("*************** request.getContextPath(): " + request.getContextPath());//System.out.println("*************** request.getRealPath(\"/\"): "+request.getRealPath("/"));//这个目前已经画删除线了System.out.println("*************** servlet.getServletContext().getRealPath(\"/\"): "+servlet.getServletContext().getRealPath("/"));System.out.println("*************** servlet.getServletContext().getRealPath(\"/WEB-INF\"): "+servlet.getServletContext().getRealPath("/WEB-INF"));System.out.println("*************** servlet.getServletContext().getRealPath(\"/WEB-INF/pic\"): "+servlet.getServletContext().getRealPath("/WEB-INF/pic"));System.out.println("*************** request.getPathInfo(): " + request.getPathInfo());System.out.println("*************** request.getServletPath(): " + request.getServletPath());System.out.println("*************** request.getRequestURI(): " + request.getRequestURI());System.out.println("*************** request.getRequestURL(): " + request.getRequestURL());System.out.println("*************** System.getProperty(\"java.io.tmpdir\"): "+System.getProperty("java.io.tmpdir"));System.out.println("*************** File.separator: "+File.separator);}
相信看完就全明白了。
阅读全文
0 0
- 关于Servlet开发中的目录
- 关于Servlet中的初始化
- 关于JAVA中的servlet
- 关于servlet中的cookie
- Web开发中的servlet
- 关于Servlet中的事件监听
- 关于servlet生命周期中的方法
- 关于servlet中的session对象
- 关于servlet中的乱码问题
- Servlet开发中的一些细节
- WEB应用开发中的Servlet
- 关于单元测试中的部署目录
- 关于项目中的目录写法
- C#中的活动目录开发
- 关于servlet 和jsp 中的 session对象
- 关于servlet 和action 中的seession 问题;
- 关于Jsp与Servlet中的Session对象
- 关于servlet 和jsp 中的 session对象
- docker_tomcat使用
- 策略模式
- C# dataset逐行读取对象数据
- 利用查找表的顺序性
- List,Set,Map用法以及区别
- 关于Servlet开发中的目录
- Java_基础—线程组和线程池的概述和使用以及线程的生命周期
- 每日一题--最小的k个数
- java 常用集合list与Set、Map区别及适用场景总结
- 表相关操作
- 小白Mac使用备忘
- pthread 之thread[线程]
- 数组排序的几种方法
- Socket通信原理简单理解