Home >Web Front-end >JS Tutorial >return steering method
Return steering method
> When using redirect, you need to traverse the last method
@RequestMapping(value = "list")
public String list(HttpServletRequest request,HttpServletResponse response,
, String> paramMap,
Model model) { directionService.findPageQuery(request, response, paramMap, model); model.addAttribute("page", page) ;
using using using ‐ ‐ - - , ;
>return VIEW_PATH + "/direction/studentDirectionConfig"; then directly returns to the page to be jumped (studentDirectionConfig is the page) after passing all the codes in this method.
> Submit with Ajax:
Step 1: Ajax submits the data to the servlet and undergoes related processing
Step 2: After the servlet, you can return msg data to the front desk through the following method: String msg= "error"; response .getWriter (). Write (msg);
Return information! (If you want to jump to the third part, otherwise the returned information will be processed accordingly, such as the pop-up prompt box in this example.)
The third part: Realize page jump through js in the foreground (if it is placed in jsp in web-inf, jsp must be deployed in web.xml, such a url will be effective, refer to: http://blog.csdn.net/wanghaiping1993/article/details/23510411 about jsp in web-inf Visit) window.location.href="${pageContext.request.contextPath}/main.jsp";
Submit the form using Ajax:
Step 1: After writing the form, submit the information to the servlet
Part 2: Use the following statement to redirect to achieve page jump (used in this way, jsp does not need to be deployed in web-inf)
request.getRequestDispatcher("/WEB-INF/ jsp/***. jsp").forward(request, response);
Example: