我已经定义了以下控制器
@Controller
公共类 HelloController {
@RequestMapping(value = "/config/{name:.*}", produces = MediaType.TEXT_PLAIN_VALUE, method = RequestMethod.GET)
@ResponseBody
ResponseEntity<String> getValue(@PathVariable String name) {
String value = "Hello World";
return new ResponseEntity<String>(HttpStatus.OK);
}
}
当我从浏览器前 ping 网址时: http://localhost:8080/example/config/test.abc
该请求工作正常。
但是当我用 url http://localhost:8080/example/config/test.uri ping
它只是用错误来炸毁页面:
The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.
我尝试了 MessageConverters 和 configureContentNegotiation 似乎没有任何工作。我想知道 spring 是否将 test.uri 视为无效模式或保留关键字。
我尝试过的环境。弹簧 4/Tomcat 7 和 8 弹簧 5/Tomcat 9