Spring MVC Controller显示404

时间:2018-07-12 08:02:19

标签: spring spring-mvc spring-boot

所有我需要帮助的 当我尝试在邮递员上访问URL时,这是我的简单控制器 显示404 =>响应,谁能告诉我它为什么来。我正在使用spring-boot项目。

@Controller
@RequestMapping(value = "/rtb")
public class RtbTestController {

    @RequestMapping(value = {"/naveen", "/nabeel", "/harsh"}, method = RequestMethod.GET)
    public ModelAndView rtbResponseValidator(HttpServletRequest request, HttpServletResponse response) {

        HashMap<String, Object> model = new HashMap<String, Object>();
        model.put("pakistan", "zindabad");
        model.put("indian", "Zindabad");

        return new ModelAndView("openRTB", model);
    }

}

1 个答案:

答案 0 :(得分:-1)

尝试一下:

@Controller
    @RequestMapping(value = "/rtb")
    public class RtbTestController {

        @RequestMapping(value = {"/naveen", "/nabeel", "/harsh"}, method = RequestMethod.GET, headers= "Accept=application/json")
        public ModelAndView rtbResponseValidator(HttpServletRequest request, HttpServletResponse response) {

            HashMap<String, Object> model = new HashMap<String, Object>();
            model.put("pakistan", "zindabad");
            model.put("indian", "Zindabad");

            return new ModelAndView("openRTB", model);
        }

    }