@RestController的方法中 路径参数带.(点号)配置



如下面这种
//http://localhost:8080/api/v1/user/info/email/test@163.com
 @RequestMapping(value = "/info/email/{email}",method = RequestMethod.GET)
    public User getInfoByEmail(@PathVariable String email){
        User user = userRepository.findByEmail(email);
        return user;
    }
 
 

 



//继承adapter 设置属性即可。
import
org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; /** * Created by Administrator on 2017/7/10 0010. */ @Configuration public class WebConfig extends WebMvcConfigurerAdapter { @Override public void configurePathMatch(PathMatchConfigurer configurer) { configurer.setUseSuffixPatternMatch(false); } }

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM