我想创建一个简单的处理程序来执行单个任务,然后将“完成”一词打印到屏幕上。
我是否需要创建 View 模板,或者是否有一种无需编写模板即可将文本打印到屏幕的简单方法?
@RequestMapping(value = "/simple_handler", method = RequestMethod.GET)
public void simpleHandler(HttpServletRequest request, ModelMap model){
this.carryOutSomeTask();
// Print "Done" on the screen
}
最佳答案
参见 http://static.springsource.org/spring/docs/3.0.x/reference/mvc.html#mvc-ann-responsebody
你只需要使用
@RequestMapping(value = "/simple_handler", method = RequestMethod.GET)
@ResponseBody
public void simpleHandler(HttpServletRequest request, ModelMap model){
this.carryOutSomeTask();
return "Done";
}
关于java - 您如何创建一个在完成任务后仅将一些文本打印到屏幕上的 Spring MVC?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6576134/