Spring boot 参数拼在访问路径中,如果参数带 点(符合)后面数据取不到
2018-01-12 16:09
435 查看
在配置类中 重写WebMvcConfigurerAdapter 的 configurePathMatch 方法,设置configurer.setUseSuffixPatternMatch(false); 即可解决。
直接上代码:
//配置类
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Autowired
private AuthInterceptorService authInterceptorService;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new GateInterceptor());
registry.addInterceptor(new AuthInterceptor(authInterceptorService));
}
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(false);
}
}
//前端代码
var Email =‘54349**@qq.com’
Tools.ajax({
url: Config.basePath + "/web/verify/AlterEmailSendNewLink/+Email ,
type: "get",
data: "",
success: function (data) {
......
}
})
如果 不加代码,后台只能取到 Email= 54349**@qq
加过代码后,后台取到值 Email= 54349**@qq.com
(完)
在@RequestMapping的value中使用SpEL来表示,value中的{version}换成{version:.+}。
终于可以再一次愉悦地进行玩耍了。
直接上代码:
//配置类
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Autowired
private AuthInterceptorService authInterceptorService;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new GateInterceptor());
registry.addInterceptor(new AuthInterceptor(authInterceptorService));
}
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(false);
}
}
//前端代码
var Email =‘54349**@qq.com’
Tools.ajax({
url: Config.basePath + "/web/verify/AlterEmailSendNewLink/+Email ,
type: "get",
data: "",
success: function (data) {
......
}
})
如果 不加代码,后台只能取到 Email= 54349**@qq
加过代码后,后台取到值 Email= 54349**@qq.com
(完)
在@RequestMapping的value中使用SpEL来表示,value中的{version}换成{version:.+}。
@RequestMapping(value="android/download/{version:.+}",method=RequestMethod.GET)public void download(HttpSession session,HttpServletResponse response,@PathVariable("version")String version){}1
终于可以再一次愉悦地进行玩耍了。
相关文章推荐
- spring-boot 实现通过访问路径后加参数返回json数据
- springboot项目所有的注入报错,而且访问不到静态数据,报错302
- springboot带参数路径访问
- Spring Boot 数据访问集成 MyBatis 与事物配置
- IntelliJ IDEA+SpringBoot中静态资源访问路径陷阱:静态资源访问404
- springboot中put请求获取不到参数解决
- spring boot整合Jersey时无法访问静态资源路径解决办法
- SpringBoot 之数据访问
- 为什么spring boot工程访问不到 静态资源
- 企业分布式微服务云SpringCloud SpringBoot mybatis (八)Spring Boot中使用Spring-data-jpa让数据访问更简单
- SpringBoot23-spingboot数据访问-Spring Data REST
- springboot【12】数据访问之NoSQL数据库MongoDB
- Spring 通过访问路径返回不同的数据格式(参考资料如下)
- 解决SpringBoot获取不到PUT方式提交的参数的问题
- springboot项目访问不到controller方法。
- SpringBoot系列三:SpringBoot基本概念(统一父 pom 管理、SpringBoot 代码测试、启动注解分析、配置访问路径、使用内置对象、项目打包发布)
- Spring Boot与Spring Security整合后post数据不了,403拒绝访问
- Spring Boot与Spring Security整合后post数据不了,403拒绝访问
- SpringBoot学习笔记 - 数据访问(Spring Data JPA)
- Spring Boot 揭秘与实战(二) 数据存储篇 - 数据访问与多数据源配置