我使用Spring Mvc和Boot创建了一个REST。它工作得很好但突然间我开始看到一个特殊的问题。
无论我在路径变量和查询参数中传递什么,都会附加句号。
控制器
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestController {
@GetMapping("/{name}")
public String test(@PathVariable(value = "name") String name, @RequestParam(value = "key") String key) {
System.out.println("Path Variable::" + name);
System.out.println("Request Param::" + key);
return "Hello " + name;
}
}
请求 http://localhost:8080/logu?key=msg
申请日志
2016-10-16 17:15:41.154 INFO 25275 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 23 ms
Interceptor : PreHandle : Request::/logu
Path Variable::logu.
Request Param::msg.
请帮我理解原因。得到附加。