路径变量不起作用 - 404资源不可用

时间:2017-03-01 22:46:05

标签: java spring

这是我的java控制器:

@Controller
@RequestMapping("/resetPassword")

@Service
public class GmiResetPasswordController {
 @RequestMapping(value = "/resetPassword/{id}/{token}", method = RequestMethod.GET)
        public
        @ResponseBody
        AnalystDetails getDetails(Model model, HttpServletRequest request, @PathVariable("id") int id, @PathVariable("token") String token) { 
//getDetails
[...]

我正在尝试使用此网址:http://localhost:8080/resetPassword/59/3e3ac731-3ac4-45eb-8bf6-5f8e4b00298c

这是我的spring security xml:

<security:http pattern="/resetPassword/**" security="none">
</security:http>

任何帮助??

修改 将控制器更改为:

@Controller
@RequestMapping("/resetPassword")
public class GmiResetPasswordController {
 @RequestMapping(value = "/{id}/{token}", method = RequestMethod.GET)
        public
        @ResponseBody
        AnalystDetails getDetails(Model model, HttpServletRequest request, @PathVariable(value = "id") int id, @PathVariable(value = "token") String token) {
[...] 
}

仍然无效..这是链接:http://localhost:8080/resetPassword/59/52ed96c3-5041-4ff9-be66-0aa2dbeca713

1 个答案:

答案 0 :(得分:0)

您的映射应该是这样的:

@Controller
@RequestMapping("/resetPassword")
public class GmiResetPasswordController {

    @RequestMapping(value = "/{id}/{token}", method = RequestMethod.GET)
    @ResponseBody
    public AnalystDetails getDetails(Model model, HttpServletRequest request, @PathVariable("id") int id, @PathVariable("token") String token) { 

        //...

    }

}