Java SpringBoot解析URI查询
我写了一个类,我尝试发送一个请求: 网址: 但我有一个错误:Java SpringBoot解析URI查询,java,spring-boot,Java,Spring Boot,我写了一个类,我尝试发送一个请求: 网址: 但我有一个错误: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.eclipse.jetty.http.BadMessageException: 400: Unable to parse URI query 代码: 这是我试过的代码,它正在运行 Spring boot主类: @SpringBo
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.eclipse.jetty.http.BadMessageException: 400: Unable to parse URI query
代码:
这是我试过的代码,它正在运行 Spring boot主类:
@SpringBootApplication
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
}
控制器代码:
@RestController
public class TestController {
@RequestMapping(value = "/*", method = RequestMethod.GET)
public String getName(@RequestParam(name = "Name", required = false) String name) {
return name;
}
}
我找到了适合我的解决方案:
@RequestMapping(value = "/*",
method = RequestMethod.GET)
public String getName(HttpServletRequest request) throws UnsupportedEncodingException {
String url = java.net.URLDecoder.decode(request.getQueryString(), "Windows-1251");
如果可能的话,你也可以粘贴请求方法代码。谢谢你的帮助:)@bulbasour111:请在帖子上“标记为答案”,如果它对你有帮助,这对其他社区成员是有益的。
@RequestMapping(value = "/*",
method = RequestMethod.GET)
public String getName(HttpServletRequest request) throws UnsupportedEncodingException {
String url = java.net.URLDecoder.decode(request.getQueryString(), "Windows-1251");