1. 程式人生 > >HTML form表單中action的正確寫法

HTML form表單中action的正確寫法

mapping oca http context java ica 現在 ont ext

  我的Java Web Application的context是myweb,即http://localhost:8080/myweb/index.jsp是歡迎頁。

  現在我的一個Controller的映射為@RequestMapping("/fileUp")。

  如果頁面的form中的action=“/fileUp”,轉向的URL為http://localhost:8080/fileUp,是無效的。

  以下是有效的寫法,會轉向“http://localhost:8080/myweb/fileUp”:

  • action="/myweb/fileUp"
  • action="./fileUp"
  • action="fileUp"

HTML form表單中action的正確寫法