How does the form form submit Json data to springmvc for background control to jump to the page and carry the data?

it is too troublesome to use the default data format of form. My data nesting is very serious, with four layers of list nesting. If spelling the name of input through the index is too painful,

so I want the form form to submit the json data, and then the data is submitted to the background, and then the background processing will jump to another page based on the data I transferred.


the background interface should not be annotated with @ ResponseBody
and then directly return "/ index". This should be fine


that's how you want to write it.

@RequestMapping(value = "/", method = RequestMethod.GET)
    public String welcome(){
        return "home/welcome.html";
}
The returned address of

should be fully written, starting under static (springboot I use)

you can jump with @ ResponseBody. I'll give you a reference

.
@RequestMapping(value = "/", method = RequestMethod.GET)
@ResponseBody
public String index() {
        return "<script>window.location.href='home/welcome.html';</script>";
}    

return "redirect:home/welcome.html";
or

@RequestMapping(value = "XX")
@ResponseBody
public String index() {
     return 
}    

then in ajax, according to the identification data window.location.href = home/welcome.html;


to allow background control to adjust, you cannot send a request using ajax.
the action execution request address of the front-end form, and the method specifies the request method;
do not add @ ResponseBody to the background interface to directly return the corresponding redirected page or redirect to another page


help you break down the problem:

using form's default data format is too troublesome. My data nesting is very serious , four layers of list nesting, if the index spelling input name is too painful.

so I want the form form to submit json data, and then submit the data to the background, and then jump to another page based on the data I transferred.

1. First of all, there is a serious problem of data nesting, which can be solved by transferring data in json format. The front end binds the json data to the specified parameter, and the back end receives the parameter and reads it in json format.

2. The second is the problem of redirecting to other pages according to the transmitted data. What you want to achieve is that controller can jump to the view specified by . Please refer to the documentation of spring. The controller can return multiple types as return values. It could be String,Model,Map,ModelAndView. Here you can return the String type to specify the name of the view, or you can return ModelAndView to specify which view.


    /**
     * @Param btPageReq 
     * @return
     */
    @RequestMapping(value = "/detailUrl", method = RequestMethod.GET)
    public String detail(@ModelAttribute("btPageReq") BtPageReq btPageReq, Model model) {
        // btPageReq data 
        model.addAttribute("data", data);
        return PREFIX + "/detail.html";
    }

ignore your needs and just look at the results. I think you can directly group complex objects at the front end and transfer the ajax to the backend. It seems better for you to jump to the page directly after the callback result is sent to the front end. And can be more convenient to feedback the results of each step, the user experience is better.


ModelAndView/request/session
return "forward:url";

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-1b3e1bf-2c3d1.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-1b3e1bf-2c3d1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?