Spring MVC @PathVariable with dot (.) is getting truncated.
转自:http://stackoverflow.com/questions/3526523/spring-mvc-pathvariable-getting-truncated
(这里只截取了问题,和笔者亲测可用的解决方案)
问题:
I have a controller that provides RESTful access to information:
@RequestMapping(method = RequestMethod.GET, value = Routes.BLAH_GET + "/{blahName}")
public ModelAndView getBlah(@PathVariable String blahName, HttpServletRequest request,
HttpServletResponse response) {
The problem I am experiencing is that if I hit the server with a path variable with special characters it gets truncated. For example:http://localhost:8080/blah-server/blah/get/blah2010.08.19-02:25:47
The parameter blahName will be blah2010.08
However, the call to request.getRequestURI() contains all the information passed in.
Any idea how to prevent Spring from truncating the @PathVariable?
回答:
Try a regular expression for the @RequestMapping argument:
RequestMapping(method = RequestMethod.GET, value = Routes.BLAH_GET + "/{blahName:.+}")
Try a regular expression for the @RequestMapping argument:
RequestMapping(method = RequestMethod.GET, value = Routes.BLAH_GET + "/{blahName:.+}")
Spring MVC @PathVariable with dot (.) is getting truncated.的更多相关文章
- Spring MVC @PathVariable被截断
一.问题描述 一个控制器提供RESTful访问信息: @RequestMapping(method = RequestMethod.GET, value = Routes.BLAH_GET + &qu ...
- Spring MVC @PathVariable注解
下面用代码来演示@PathVariable传参方式 @RequestMapping("/user/{id}") public String test(@PathVariable(& ...
- Spring MVC @PathVariable 特殊字符
1.问题 SpringMVC项目中通过下面的URL进行GET请求.当version有多个小数点的时候.如version为1.0.1008.后台通过@PathVariable来获取version等于1. ...
- Spring MVC @PathVariable注解(3)
下面用代码来演示@PathVariable传参方式 1 @RequestMapping("/user/{id}") 2 public String test(@PathVariab ...
- spring mvc中的@PathVariable(转)
鸣谢:http://jackyrong.iteye.com/blog/2059307 ------------------------------------------------ spring m ...
- spring mvc:练习 @RequestParam(参数绑定到控制器)和@PathVariable(参数绑定到url模板变量)
spring mvc:练习 @RequestParam和@PathVariable @RequestParam: 注解将请求参数绑定到你的控制器方法参数 @PathVariable: 注释将一个方法参 ...
- spring mvc中的@PathVariable
spring mvc中的@PathVariable是用来获得请求url中的动态参数的,十分方便,复习下: @Controller public class TestController { @Requ ...
- [Java] Spring MVC 知识点
云图: @Service 用于标注业务层组件. 在 Spring-servlet 配置xml中,component-scan 标签默认情况下自动扫描指定路径下的包(含所有子包),将带有@Compone ...
- Spring mvc中@RequestMapping 6个基本用法
Spring mvc中@RequestMapping 6个基本用法 spring mvc中的@RequestMapping的用法. 1)最基本的,方法级别上应用,例如: Java代码 @Reques ...
随机推荐
- 可回味的js代码段
1,关于bind()----- var name="global"; var person={ name:"person", hello:function(st ...
- android 百度地图 定位功能
废话不多说 直接新建一个新android项目:location,然后花一分钟申请一个key,然后就是把百度定位demo抄一下即可 1:首先在AndroidManifest.xml中加入权限 <u ...
- 2015多校联合训练赛 hdu 5308 I Wanna Become A 24-Point Master 2015 Multi-University Training Contest 2 构造题
I Wanna Become A 24-Point Master Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 ...
- JSTL函数标签
tld 文件代码 <?xml version="1.0" encoding="UTF-8" ?> <taglib xmlns="ht ...
- 《linux 内核全然剖析》 笔记 CODE_SPACE 宏定义分析
在memory.c里面.遇到一个宏定义,例如以下: #define CODE_SPACE(addr) ((((addr)+4095)&~4095) < \ current->sta ...
- POJ3255 Roadblocks 严格次短路
题目大意:求图的严格次短路. 方法1: SPFA,同时求单源最短路径和单源次短路径.站在节点u上放松与其向量的v的次短路径时时,先尝试由u的最短路径放松,再尝试由u的次短路径放松(该两步并非非此即彼) ...
- ubuntu清华源【转】
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/ 可以选择ubuntu的版本更新源.
- ES 断路器——本质上保护OOM提前抛出异常而已
监控fielddata使用了多少内存以及是否有数据被驱逐是非常重要的.大量的数据被驱逐会导致严重的资源问题以及不好的性能. Fielddata使用可以通过下面的方式来监控: 对于单个索引使用 {ref ...
- python spark 决策树 入门demo
Refer to the DecisionTree Python docs and DecisionTreeModel Python docs for more details on the API. ...
- Elo rating system(Elo 打分体系)
A.B 两个待比较.评价的对象,分别打分为 RA,RB,则各自获胜的期望值为: ⎧⎩⎨⎪⎪⎪⎪⎪⎪EA=11+10(RB−RA)/400.EB=11+10(RA−RB)/400. 不妨令 QA=10R ...