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 中:有斜杠访问的是绝对地址,没有斜杠访问的相对地址

可参见:

https://blog.csdn.net/a1044909923/article/details/94738339

 

版权声明:本文为helloqiufei原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/helloqiufei/archive/2004/01/13/11655309.html