jsp 页面如下:
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Login</title> </head> <body> <form action = "/login" method="post"> username:<input name = "username" value = "username"> <br><br> password:<input type = "password" name = "password" value = "password"> <br><br> <input type = "submit" vlaue = "submit"> </form> </body> </html>
然后点击提交之后,访问的地址为http://localhost:8080/login
这个地址就没有项目名http://localhost:8080/maventest_war_exploded/list.jsp
将action 前面“/”后去掉后如下:
--%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Login</title> </head> <body> <form action = "login" method="post"> username:<input name = "username" value = "username"> <br><br> password:<input type = "password" name = "password" value = "password"> <br><br> <input type = "submit" vlaue = "submit"> </form> </body> </html>
点击提交后地址栏为://localhost:8080/maventest_war_exploded/login
总结
action 中:有斜杠访问的是绝对地址,没有斜杠访问的相对地址
可参见: