Home > Back-end >  Send an ajax request to return after for SpringMVC ModelAndView data to the JSP, JSP, receive less t
Send an ajax request to return after for SpringMVC ModelAndView data to the JSP, JSP, receive less t

Time:09-16











CodePudding user response:

The type, you tyoe

CodePudding user response:

Ajax can't return to the modelandview view, you enter the page should also by the success of localtion. Href entered, is not a parameter

CodePudding user response:

Add a @ ResponseBody

CodePudding user response:

ModelAndView object only once in a life cycle request, request it inside the domain values of a, there is no next time

CodePudding user response:

Returns a json string

CodePudding user response:

Usually AJAX returns are JSON string,
According to your intentions, can jump page first, then the AJAX request data, and then parse AJAX the returned JSON string to page assignment,

CodePudding user response:

You are now back to view or @ ResponseBody yao the GetMapping instead

CodePudding user response:

I wipe is all some talent
AJAX=Asynchronous JavaScript and XML (Asynchronous JavaScript and XML),

AJAX is not a new programming language, it is a new method of using the existing standard

AJAX is part exchange data with the server and updates the web page art, without reloading the whole page,

CodePudding user response:

Ajax is returned json, so there is no ModelAndView value,

CodePudding user response:

Regardless of the operator is not logical, you,

Analyze your code:
1. Ajax access/product/productDetails
2. Add a, attribute values to aaa Model, then the view for product_details (I doubt here last and rendering product_details. JSP, if it is not too logical)
3. After the success of the access page jump to product_details. JSP, here a new request, access is not the same it with ajax, so the attribute is bound drops less than

If you want to take to the value, there are two ways:
1. Parameter method is passed: add @ ResponseBody productDetails this method above, method inside what also not stem, direct return "aaa", ajax success method content to the window. The location. The href="https://bbs.csdn.net/topics/product_details.jsp? A="+ response, JSP inside contents change request. The getParameter (" a")

2. Use the session save, JSP inside value after deletion
  • Related