Tag Archives: Request processing failed

How to Solve SSM Error: Request processing failed; nested exceptionis java.lang.NullPointerExceptio

Recently, in Android studio, an app operated by the front desk of a food and beverage management system server, using SSM framework as the server, reported an error as shown in the following figure when the app called the server:

To be exact, one of the most important mistakes is: request processing failed; nested exception

Is java.lang.nullpointerexceptio, which means that the request processing fails, and the nested exception is java.lang.nullpointerexceptio null pointer exception

After some breakpoint troubleshooting, I found that the problem appeared in the implementation interface of service. When the service called the Dao layer, it reported an error. If I think about it in detail, it might be that there was a problem when referring to the Dao layer. Then I went to check the code of the Dao layer and found the problem, It’s obvious from the picture that I omitted the annotation @ Autowired when referring to the Dao layer. Later, I added the annotation and then operated. The problem was solved

terms of settlement:

This time there will be such a problem is completely caused by their own carelessness and carelessness, so we must be careful when writing code, we must be careful to find problems

Finally, let’s popularize the function of @ Autowired

Autowired is the core annotation of spring. It can annotate class member variables, methods and constructors, so that spring can complete the automatic assembly of beans@ Autowired matches beans by class by default, and assembles beans by name according to @ qualifier specification. It is also the automatic assembly of IOC

How to Solve Request processing failed; nested exception is java.lang.NullPointerException

1) Scene: use the request object under the HttpServletRequest package to perform the query request.getAttribute () and request.setAttribute () null pointer exception when assigning value
2) reason:
error example code:

because the value of provinceid is not assigned to the page before the jump, and then the value is assigned to the control layer here, but there is no provinceid object in the request object at all, so the tostring() of an empty object will definitely cause an error

3) Solution: however, we need to get the value in the form of string to prevent the occurrence of null pointer (that is, provinceid does not exist in the request object at all). We need to judge whether the request object is null

if(request.getAttribute("provinceId")!=null){
    //Execute the corresponding operation e.g. output
    String provinceId=request.getAttribute("provinceId").toString();
    System.out.println(provinceId)
}

Reminder: when the four common value taking methods in the controller operate, the received object must be judged to be null, and the object cannot be directly toString