diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java index 875a7cc8..9dd3df9c 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java @@ -60,7 +60,12 @@ public class PlayerSettingsController { private TranscodingService transcodingService; @RequestMapping(method = RequestMethod.GET) - protected String formBackingObject(HttpServletRequest request, Model model) throws Exception { + protected String displayForm() throws Exception { + return "playerSettings"; + } + + @ModelAttribute + protected void formBackingObject(HttpServletRequest request, Model model) throws Exception { handleRequestParameters(request); List players = getPlayers(request); @@ -103,11 +108,10 @@ public class PlayerSettingsController { command.setAdmin(user.isAdminRole()); model.addAttribute("command",command); - return "playerSettings"; } @RequestMapping(method = RequestMethod.POST) - protected String doSubmitAction(@ModelAttribute PlayerSettingsCommand command, Model model) throws Exception { + protected String doSubmitAction(@ModelAttribute("command") PlayerSettingsCommand command, Model model) throws Exception { Player player = playerService.getPlayerById(command.getPlayerId()); player.setAutoControlEnabled(command.isAutoControlEnabled()); @@ -121,7 +125,6 @@ public class PlayerSettingsController { transcodingService.setTranscodingsForPlayer(player, command.getActiveTranscodingIds()); command.setReloadNeeded(true); - model.addAttribute("command",command); return "redirect:playerSettings.view"; } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/SearchController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/SearchController.java index 3c5144d1..7ee3fbe8 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/SearchController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/SearchController.java @@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindException; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; @@ -66,13 +67,17 @@ public class SearchController { private SearchService searchService; @RequestMapping(method = RequestMethod.GET) - protected String formBackingObject(HttpServletRequest request, Model model) throws Exception { - model.addAttribute("command",new SearchCommand()); + protected String displayForm() throws Exception { return "search"; } + @ModelAttribute + protected void formBackingObject(HttpServletRequest request, Model model) throws Exception { + model.addAttribute("command",new SearchCommand()); + } + @RequestMapping(method = RequestMethod.POST) - protected String onSubmit(HttpServletRequest request, HttpServletResponse response, SearchCommand command, Model model) + protected String onSubmit(HttpServletRequest request, HttpServletResponse response,@ModelAttribute("command") SearchCommand command, Model model) throws Exception { User user = securityService.getCurrentUser(request); @@ -101,7 +106,6 @@ public class SearchController { command.setPlayer(playerService.getPlayer(request, response)); } - model.addAttribute("command",command); return "search"; }