@RequestMapping(value = "/htmlorjson/{type}", method = {RequestMethod.GET, RequestMethod.POST})
public ModelAndView ajaxPaymentBatchApproveProcess(@PathVariable String type)
{
if ("html".equals(type))
{
//index表示指定路径下的jsp页面的名称
ModelAndView mav = new ModelAndView("index");
return mav;
}
else
{
ModelAndView mav = new ModelAndView(new MappingJackson2JsonView());
mav.addObject("result", "failed");
return mav;
}
}
Spring MVC 同一个方法同时返回view或json
最新推荐文章于 2023-09-05 21:48:15 发布