Spring MVC如何在没有返回(字符串)视图的情况下创建控制器? [英] Spring MVC how to create controller without return (String) view?
问题描述
以下是我的示例控制器.
The below is my sample controller.
@RequestMapping(value = "/validate", method = RequestMethod.POST)
public String validatePage1 (@ModelAttribute("page1")
Page1 pg1, BindingResult result) {
System.out.println("Value1:" + pg1.getVal1() +
"Value2:" + pg1.getVal2());
return "page2"; // I don't want to take any action (page navigation) here
}
@RequestMapping("/page1")
public ModelAndView pageShow() {
return new ModelAndView("page1", "command", new Page1());
}
现在的问题是,当Spring框架调用方法(validatePage1)时,我不想在客户端采取任何措施,怎么办?
Now the question is, I don't want to take any action in the client side when the method (validatePage1) is called by Spring framework, how to do?
实际上,我在加载时已在客户端加载了所有必需的页面(以避免重复页面加载),所以我不想在客户端执行任何页面导航操作,我只想执行数据绑定"在服务器端完成我的业务逻辑.
Actually I have loaded all required pages in my client side at loading time (to avoid repeated page load), so I dont want to take any page navigation action in the client side, I just want to do the 'data binding' to complete my business logic in server side.
当我在"validatePage1()"中返回"空字符串时,Spring框架将引发异常请求处理失败;嵌套异常为org.apache.tiles.definition.NoSuchDefinitionException:",因为我正在使用图块,因此必须删除稍后进行磁贴配置,因为我是在第一次加载自身时加载所有文件.
When I return "" empty string in "validatePage1()", Spring framework throws exception " Request processing failed; nested exception is org.apache.tiles.definition.NoSuchDefinitionException:" since I am using tiles, I have to remove tiles configuration later since I am loading all files at first loading itself.