kerwin612 opened a new issue, #5057:
URL: https://github.com/apache/shenyu/issues/5057

   ### Is there an existing issue for this?
   
   - [X] I have searched the existing issues
   
   ### Current Behavior
   
   In the `springmvc` project, after adding the configuration of 
`spring.mvc.servlet.path` or `server.servlet.context-path`, the API path 
registered to the gateway is incorrect
   
   ### Expected Behavior
   
   Expect to register the correct API path to the gateway
   
   ### Steps To Reproduce
   
   1. git clone shenyu@master
   2. edit 
`shenyu-examples/shenyu-examples-springmvc/src/main/resources/application.yml`
   3. launch admin and bootstrap and shenyu-examples-springmvc
   4. debug api in admin dashboard.
   
   diff 
`shenyu-examples/shenyu-examples-springmvc/src/main/resources/application.yml`
   ```bash
   diff --git 
a/shenyu-examples/shenyu-examples-springmvc/src/main/resources/application.yml 
b/shenyu-examples/shenyu-examples-springmvc/src/main/resources/application.yml
   index 9fb5a6a..a7d5386 100644
   --- 
a/shenyu-examples/shenyu-examples-springmvc/src/main/resources/application.yml
   +++ 
b/shenyu-examples/shenyu-examples-springmvc/src/main/resources/application.yml
   @@ -17,13 +17,17 @@ server:
      port: 8289
      address: 0.0.0.0
      servlet:
   -    context-path: /
   +    context-path: /test
      tomcat:
        max-http-form-post-size: 100MB
   +
    spring:
   +  mvc:
   +    servlet:
   +      path: /api
   
   ```  
   
   The curl of the debugging API is as follows:  
   ```bash
   curl 'http://127.0.0.1:9095/sandbox/proxyGateway' \
     -H 'Accept: */*' \
     -H 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6' \
     -H 'Cache-Control: no-cache' \
     -H 'Connection: keep-alive' \
     -H 'Content-Type: application/json' \
     -H 'Cookie: JSESSIONID=BCC29CACFEF7B48C101FA3EB293F6970' \
     -H 'Origin: http://127.0.0.1:9095' \
     -H 'Pragma: no-cache' \
     -H 'Referer: http://127.0.0.1:9095/' \
     -H 'Sec-Fetch-Dest: empty' \
     -H 'Sec-Fetch-Mode: cors' \
     -H 'Sec-Fetch-Site: same-origin' \
     -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 
Edg/115.0.1901.203' \
     -H 'X-Access-Token: 
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjkyNjE3ODc4fQ.Yb8G12vZDNBPtZzi9cVzy29cv6lBdoTnh8JVr4Ycc7c'
 \
     -H 'sec-ch-ua: "Not/A)Brand";v="99", "Microsoft Edge";v="115", 
"Chromium";v="115"' \
     -H 'sec-ch-ua-mobile: ?0' \
     -H 'sec-ch-ua-platform: "Windows"' \
     --data-raw 
'{"httpMethod":"GET","querys":"{}","bizParam":{},"headers":{"Content-type":"application/x-www-form-urlencoded"},"requestUrl":"http://127.0.0.1:9195/mvc/order/findById"}'
 \
     --compressed
   ```  
   
   response error:
   ```html
   <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not 
Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} 
h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 
{font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} 
.line 
{height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP 
Status 404 – Not Found</h1></body></html>
   ```
   
   
   ### Environment
   
   ```markdown
   ShenYu version(s): master
   ```
   
   
   ### Debug logs
   
   ```bash
   [shenyu-netty-nio-3] INFO  
org.apache.shenyu.plugin.base.AbstractShenyuPlugin - contextPath selector match 
success from default strategy
   [shenyu-netty-nio-3] INFO  
org.apache.shenyu.plugin.base.AbstractShenyuPlugin - contextPath selector 
success match , selector name :/mvc
   [shenyu-netty-nio-3] INFO  
org.apache.shenyu.plugin.base.AbstractShenyuPlugin - contextPath rule success 
match , rule name :/mvc
   [shenyu-netty-nio-3] INFO  
org.apache.shenyu.plugin.base.AbstractShenyuPlugin - divide selector match 
success from default strategy
   [shenyu-netty-nio-3] INFO  
org.apache.shenyu.plugin.base.AbstractShenyuPlugin - divide selector success 
match , selector name :/mvc
   [shenyu-netty-nio-3] INFO  
org.apache.shenyu.plugin.base.AbstractShenyuPlugin - divide rule success match 
, rule name :/mvc/order/findById
   [shenyu-netty-nio-3] DEBUG 
org.apache.shenyu.plugin.httpclient.AbstractHttpClientPlugin - The request 
urlPath is: http://192.168.56.1:8289/order/findById, retryTimes is : 3, 
retryStrategy is : current
   ```
   
   ### Anything else?
   
   [Spring Web MVC - Path 
Matching](https://docs.spring.io/spring-framework/reference/web/webmvc/mvc-servlet/handlermapping-path.html)
    
   
   [Context Path vs. Servlet Path in 
Spring](https://www.baeldung.com/spring-context-vs-servlet-path)  
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to