Configure the following servlet path in application.yml
spring:
mvc:
servlet:
path: /api
Access the GET /api/persons/666 interface,The console throws the following error.
java.lang.UnsupportedOperationException: null
at org.springframework.web.util.ServletRequestPathUtils$ServletRequestPath.modifyContextPath(ServletRequestPathUtils.java:221) ~[spring-web-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.function.RequestPredicates$SubPathServerRequestWrapper.requestPath(RequestPredicates.java:944) ~[spring-webmvc-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.function.RequestPredicates$SubPathServerRequestWrapper.<init>(RequestPredicates.java:933) ~[spring-webmvc-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.function.RequestPredicates$PathPatternPredicate.lambda$nest$0(RequestPredicates.java:519) ~[spring-webmvc-5.3.31.jar:5.3.31]
at java.base/java.util.Optional.map(Optional.java:260) ~[na:na]
at org.springframework.web.servlet.function.RequestPredicates$PathPatternPredicate.nest(RequestPredicates.java:519) ~[spring-webmvc-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.function.RouterFunctions$DefaultNestedRouterFunction.route(RouterFunctions.java:1027) ~[spring-webmvc-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.function.RouterFunctionBuilder$BuiltRouterFunction.route(RouterFunctionBuilder.java:392) ~[spring-webmvc-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.function.RouterFunctions$DifferentComposedRouterFunction.route(RouterFunctions.java:928) ~[spring-webmvc-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.function.support.RouterFunctionMapping.getHandlerInternal(RouterFunctionMapping.java:220) ~[spring-webmvc-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:498) ~[spring-webmvc-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1266) ~[spring-webmvc-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1048) ~[spring-webmvc-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:965) ~[spring-webmvc-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.31.jar:5.3.31]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.31.jar:5.3.31]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:529) ~[tomcat-embed-core-9.0.83.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.31.jar:5.3.31]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:623) ~[tomcat-embed-core-9.0.83.jar:4.0.FR]
Define a RouterFunction:
Configure the following servlet path in application.yml
Access the GET /api/persons/666 interface,The console throws the following error.
version: Spring5.x and Spring6.x