添加Axios请求
This commit is contained in:
@@ -19,7 +19,7 @@ import java.io.IOException;
|
||||
*/
|
||||
@WebFilter("/*")// 过滤器所有的请求
|
||||
public class UserSessionFilter implements Filter {
|
||||
private String[] excludeUrls = new String[]{"/login", "/register", "/VerifycodeServlet"};
|
||||
private String[] excludeUrls = new String[]{"/login", "/register", "/VerifycodeServlet","/ExUserNameServlet"};
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
|
42
src/com/landaiqing/servlet/ExUserNameServlet.java
Normal file
42
src/com/landaiqing/servlet/ExUserNameServlet.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.landaiqing.servlet;
|
||||
|
||||
|
||||
import com.landaiqing.entity.UserEntity;
|
||||
import com.landaiqing.service.UserService;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.annotation.WebServlet;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* http://localhost:8080/mayikt_session_war_exploded/exUserNameServlet?name=1
|
||||
* @author 余胜军
|
||||
* @ClassName ExUserNameServlet
|
||||
* @qq 644064779
|
||||
* @addres www.mayikt.com
|
||||
* 微信:yushengjun644
|
||||
*/
|
||||
@WebServlet("/exUserNameServlet")
|
||||
public class ExUserNameServlet extends HttpServlet {
|
||||
|
||||
private UserService UserService = new UserService();
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("text/html;charset=utf-8");
|
||||
//1.获取到用户输入的userName参数值
|
||||
String userName = req.getParameter("userName");
|
||||
//2.调用数据库根据userName查询用户名称是否存在
|
||||
UserEntity mayiktUserEntity = UserService.findByUserName(userName);
|
||||
PrintWriter writer = resp.getWriter();
|
||||
if (mayiktUserEntity != null) {
|
||||
writer.print("该用户" + userName + "已经存在的 无法注册!");
|
||||
}
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user