下面是源码求大佬解答
package com.aitiguigu.Servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class servlet01 extends HttpServlet{
@Override
protected void service(HttpServletRequest req, HttpServletResponse resq) throws ServletException, IOException {
String username = req.getParameter("username");
String info="YES";
if("shuangshuang".equals(username)) {
info="NO";
}
PrintWriter writer = resq.getWriter();
writer.write(info);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
id="WebApp_ID" version="4.0">
<servlet>
<servlet-name>userServlet</servlet-name>
<servlet-class>com.aitiguigu.Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>userServlet</servlet-name>
<url-pattern>/userServlet </url-pattern>
</servlet-mapping>
</web-app>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form mothod="get" action="userServlet">
用户名:<input type="text" name="username"> <br>
<input type="submit" value="校验">
</form>
</body>
</html>