Spring forward无法在android api中运行

时间:2017-04-21 08:00:07

标签: spring-mvc

我一直在谷歌上搜索,但我找不到解决方案所以请告诉我为什么spring forward在android api中没有工作但是在web api工作所以如何修复它?

@Controller
@RequestMapping(value = "/")
public class LoginController {

@RequestMapping(method = {RequestMethod.GET,RequestMethod.POST,RequestMethod.HEAD})
    public ModelAndView home(@ModelAttribute LoginInfo user, Model model,
    HttpServletRequest request, HttpServletResponse response)throws Exception {
        System.out.println("LoginController.user.userName: "+userName);
        return new ModelAndView("forward:admin.html");
      }

    @RequestMapping(value = "/admin", method={RequestMethod.GET, RequestMethod.POST})
    public ModelAndView successAdmin(@ModelAttribute LoginInfo user, Model model,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        System.out.println("admin.userName: "+userName);
        return null;
    }


}

我也使用return new ModelAndView(“forward:/admin.html”);但不要将请求转发给/ admin处理程序方法。

1 个答案:

答案 0 :(得分:0)

尝试使用

return new ModelAndView("admin.html");

在您的家庭方法

或将家庭功能更改为

public String home() {   
    return "forward:/admin";
}}