spring:客户端发送的请求在语法上不正确()

嗨,我在重定向期间收到了下一个错误:

客户端发送的请求在语法上不正确

浏览器显示的URL是:localhost:8080/Project/menu/main/home/0在这里,我的类首先进行重定向-“从”重定向,然后进行“重定向”到:

 /*

* Get all possible values of menu and generate correct url to pages controllers

*

*/

@Controller

@SessionAttributes("menu")

public class MainMenuController {

@ModelAttribute

public Menu createMenu() {

return new Menu();

}

@RequestMapping(value = "/menu", method = RequestMethod.GET)

public String mainMenuResolver(@ModelAttribute Menu menu) {

menu.setMainMenu("first");

return "forward:/menu/first";

}

@RequestMapping(value = "/menu/{mainMenu}", method = RequestMethod.GET)

public String subMenuResolver(@PathVariable String mainMenu, @ModelAttribute Menu menu) {

menu.setMainMenu(mainMenu);

menu.setSubMenu("home");

return "forward:/menu/first/home";

}

@RequestMapping(value = "/menu/{mainMenu}/{subMenu}", method = RequestMethod.GET)

public String secMenuResolver(@PathVariable String mainMenu, @PathVariable String subMenu, @ModelAttribute Menu menu) {

menu.setMainMenu(mainMenu);

menu.setSubMenu(subMenu);

menu.setSecMenu("0");

if (menu.getMainMenu().equals("first")){

return "redirect:/menu/main/"+menu.getSubMenu()+"/"+menu.getSecMenu();

}

if (menu.getMainMenu().equals("second")){

return "redirect:/menu/religion/"+menu.getSubMenu()+"/"+menu.getSecMenu();

}

return "redirect:/menu/main/"+menu.getSubMenu()+"/"+menu.getSecMenu();

}

}

第二类:

@Controller

@SessionAttributes("menu")

public class FirstPageController {

@ModelAttribute

public Menu createMenu() {

return new Menu();

}

@RequestMapping(value = "/menu/main/{subMenu}/{secMenu}", method = RequestMethod.GET)

public ModelAndView menuResolver(@PathVariable String mainMenu, @PathVariable String subMenu,@PathVariable String secMenu, @ModelAttribute("menu") Menu menu) {

menu.setMainMenu(mainMenu);

menu.setSubMenu(subMenu);

menu.setSecMenu(secMenu);

if (menu.getSubMenu().equals("home")){

String title = "Project - Home Page";

return new ModelAndView("MainPage", "title", title);

}

String title = "Project - Home Page";

return new ModelAndView("MainPage", "title", title);

}

}

:我解决了它,第二类的方法中有多余的参数。

回答:

在这种情况下,将org.springframework.web登录级别设置为DEBUGinlog4j configuration

<logger name="org.springframework.web">

<level value="DEBUG" />

...

</logger>

例如,当缺少参数或无法将其转换为所需的类型时,日志中将出现异常详细信息。

以上是 spring:客户端发送的请求在语法上不正确() 的全部内容, 来源链接: utcz.com/qa/427562.html

回到顶部