JavaWeb常見問題辨析

轉發,重定向和前段界面跳轉的路徑的區別

屬性 轉發 重定向 前端界面跳轉
地址欄的變化 地址欄不變 地址欄變化 地址欄變化
直接寫接口名
(無/)
- localhost:8080/項目名/…/接口信息 同左
接口名
(有/)
localhost:8080/項目名/接口 同右 localhost:8080/接口
  • 注:
    • …/ =======>返回上一層
    • ${request.getContextpath}=====> localhost:8080/項目名

獲取路徑解析

方法名 含義
request.getRealPath("/");
request.getSession().getServletContext().getRealPath("/");
application.getRealPath("")【jsp中 】
System.getProperty(“user.dir”);
ServletContext().getRealPath("")
獲取(服務器)工程的根(絕對)路徑
獲取web服務器下的文件路徑
request.getServletPath() 當前頁面所在目錄下全名稱(相對路徑)
request.getParameter(“myFile”);
ActionForm.getMyFile();
獲取本地路徑(絕對)

待續~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章