Browse Source

apiController中 request.getRequestURI() 修改为request.getServletPath()

4.0
FLYPHT 2 years ago
parent
commit
7310fabce0
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/controller/ApiController.java

+ 2
- 2
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/controller/ApiController.java View File

@@ -29,7 +29,7 @@ public class ApiController {
@GetMapping(value = "/api/**", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE}) @GetMapping(value = "/api/**", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
public Object commonGet(@RequestParam Map<String, Object> params, public Object commonGet(@RequestParam Map<String, Object> params,
HttpServletRequest request, HttpServletResponse response) throws Exception { HttpServletRequest request, HttpServletResponse response) throws Exception {
String apiUrl = request.getRequestURI().substring(5);
String apiUrl = request.getServletPath().substring(5);
return methodAccessManager.invoke(apiUrl, params, null, request, response); return methodAccessManager.invoke(apiUrl, params, null, request, response);
} }


@@ -45,7 +45,7 @@ public class ApiController {
@PostMapping(value = "/api/**", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE}) @PostMapping(value = "/api/**", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
public Object commonPost(@RequestParam Map<String, Object> params, @RequestBody(required = false) String body, public Object commonPost(@RequestParam Map<String, Object> params, @RequestBody(required = false) String body,
HttpServletRequest request, HttpServletResponse response) throws Exception { HttpServletRequest request, HttpServletResponse response) throws Exception {
String apiUrl = request.getRequestURI().substring(5);
String apiUrl = request.getServletPath().substring(5);
// 保证body在post的清空下不为null,用于区分get时吧参数组合成body // 保证body在post的清空下不为null,用于区分get时吧参数组合成body
if (body == null) { if (body == null) {
body = ""; body = "";


Loading…
Cancel
Save