Ajax data check the foreground did not get the data.

function check() {//js
        var text = document.getElementById("xh").value;//id
        if (text == "") {
            alert("");//
            return false;//false
        }
        if (!(/(^[1-9]\d*$)/.test(text))) {
            alert("");//
            return false;//false
        }
        var student_id = $("-sharpstudent_id").val();

        $.ajax({
            url : "<%=basePath%>user/queryByUser",
            type : "post",
            data : {
                "student_id" : student_id
            },
            dataType : "json",
            success : function(data) {
                if (data != null) {
                    alert("");
                } else if (data == null && student_id != "") {
                    alert("");
                    return false;
                }
            }
        });
        return true;//
    }
</script>
<body>
    <div class="listDIV">
        <table id="FileTable" border="1" width="50%" height="50%"
            style="text-align: center;">
            <form action="<%=basePath%>user/one" method="post">
                <input type="text" id="xh" name="student_id" placeholder="">
                <button class="glyphicon glyphicon-select" onclick="return check();"></button>
            </form>
@ResponseBody
    @RequestMapping(value="/queryByUser", method=RequestMethod.POST,produces="application/json;charset=UTF-8")  
    public Student queryByName(Integer student_id,HttpServletRequest request){
       Student s= userService.getStudent_id(student_id);
       s.getStudent_id();
       return s;
   }
<!-- student_id -->
    <select id="getStudent_id" resultMap="studentMap" parameterType="int">
         SELECT * from student where student_id = -sharp{student_id}
    </select>

error message

: Servlet.service() for servlet [springMVC] in context with path [/StudentManagementSSM] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException
    at com.zmk.controller.UserTestController.queryByName(UserTestController.java:66)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1139)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Sep.06,2021

.jsp

function check() {//js
        var flag = true;
        var text = document.getElementById("xh").value;
        if (!(/(^[1-9]\d*$)/.test(text))) {//
            alert("");
            flag = false;
            //alert(flag);
        }
            var student_id = $('input[name="student_id"]').val();//input
            //alert(student_id);
            $.ajaxSetup({
                  async: false//
                  });
            $.post("<%=basePath%>user/queryByID", {student_id : student_id},function(data){
                //alert(data);
                if (!data) {//
                    alert("");
                    flag = false;
                    //alert(flag);
                }
            });
        //alert("======"+flag);
        return flag;
    }

controller layer

@ResponseBody
    @RequestMapping(value = "/queryByID", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public Student queryByID(Integer student_id, HttpServletRequest request) {//id
        Student student = userService.getStudent_id(student_id);
        try {
            if (student.getName() == null) {
                System.out.println("111");
            } else {
                System.out.println("");
                System.out.println(student_id);
            }
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
            System.out.println("");
        }
        return student;//ajax,null
    }
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a5f7-2b986.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a5f7-2b986.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?