阅读背景:

Spring MVC 同一个方法同时返回view或json

来源:互联网 
@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;
        }
    }@RequestMapping(value = "/htmlorjson/{type}", m



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: