我在代码中使用百里叶,在这里返回类型是字符串,但我希望返回类型如下:public Response abc(){.. r


@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String helloForm()
{
    return "helloform";
}
@RequestMapping(value = "/hello", method = RequestMethod.POST)
public String hello(HttpServletRequest request,Model model) {
    String name = request.getParameter("name");
    if (name == null) {
        name = "world";
    }
  // do what you want to code....
  model.addAttribute("message",HelloMessage.getMessage(name));
   // return "<h1>" + HelloMessage.getMessage(name) + "</h1>";
    return "hello";
}

在方法中尝试@Responsebody,并在模型中设置视图名称。

相关内容

最新更新