zoukankan      html  css  js  c++  java
  • java关于用request获取路径

    System.out.println("getContextPath:"+req.getContextPath());
    System.out.println("getServletPath:"+req.getServletPath());
    System.out.println("getRequestURI:"+req.getRequestURI());
    System.out.println("getRequestURL:"+req.getRequestURL());
    System.out.println("getRealPath:"+req.getSession().getServletContext().getRealPath("image") );

    输出结果为

    getContextPath:/maven
    getServletPath:/upload.do
    getRequestURI:/maven/upload.do
    getRequestURL:http://localhost:8080/maven/upload.do
    getRealPath:D:myecllipseapache-tomcat-7.0.77-windows-x64apache-tomcat-7.0.77wtpwebappshcwprojectimage

    最后一个路径其实是工程在那个目录运行路径,不该路径默认会在工作空间

  • 相关阅读:
    spring mvc 分页
    get/post时中文乱码问题的解决办法
    mysql-day01
    servler配置
    idea
    springMvc 核心配置
    ServletRequest面试题
    Servlet面试题
    Http面试题
    测试文件
  • 原文地址:https://www.cnblogs.com/itzyz/p/12262266.html
Copyright © 2011-2022 走看看