编程语言
首页 > 编程语言> > javaweb项目中jsp的from表单提交action内容与web.xml的servlet-mapping对应

javaweb项目中jsp的from表单提交action内容与web.xml的servlet-mapping对应

作者:互联网

login.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>demo</title>
  </head>
  <body>
  <form action="login" method="post">
  user:<input type="text" name="user">
  passsord<input type="password" name="password">
    <input type="submit" name="提交">
  </form>
  </body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <servlet>
        <servlet-name>loginServlet</servlet-name>
        <servlet-class>com.psl.loginServlet.LoginServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>loginServlet</servlet-name>
        <url-pattern>/login</url-pattern>
    </servlet-mapping>
</web-app>

注意:action的URI不加"/"

标签:xml,web,javaweb,jsp,action,login,loginServlet
来源: https://www.cnblogs.com/pengsulong/p/13420112.html