【发布时间】:2019-03-21 14:51:22
【问题描述】:
我已经定义了下面的控制器
@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 url 时: http://localhost:8080/example/config/test.abc
请求工作正常。
但是当我用 url ping http://localhost:8080/example/config/test.uri
它只是用错误来炸毁页面:
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/雄猫 7 & 8 Spring 5/Tomcat 9
【问题讨论】:
标签: spring spring-mvc