[英]How to set spring dispatcherServlet path?
I use application.properties file to set DispatcherServlet
path:我使用application.properties文件来设置
DispatcherServlet
路径:
server.servlet.path=/api/
When I go to url /api/
, I get this exception:当我 go 到 url
/api/
时,我得到这个异常:
Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'servlet[path]' of bean class [org.springframework.boot.autoconfigure.web.ServerProperties]: Bean property 'servlet[path]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:731)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:948)
... 59 common frames omitted
How to set DispatcherServlet path?如何设置 DispatcherServlet 路径?
您始终可以查看Spring 属性附录以找到您想要的属性:
server.servlet-path=/ # Path of the main dispatcher servlet.
Use spring.mvc.servlet.path=/api
since server.servlet.path
got deprecated使用
spring.mvc.servlet.path=/api
因为server.servlet.path
已弃用
It's spring.mvc.servlet.path
now (2.3.x).现在是
spring.mvc.servlet.path
(2.3.x)。 Let's see when it changes again :)让我们看看它什么时候再次改变:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.