转自: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:.+}")

Spring MVC @PathVariable with dot (.) is getting truncated.的更多相关文章

  1. Spring MVC @PathVariable被截断

    一.问题描述 一个控制器提供RESTful访问信息: @RequestMapping(method = RequestMethod.GET, value = Routes.BLAH_GET + &qu ...

  2. Spring MVC @PathVariable注解

    下面用代码来演示@PathVariable传参方式 @RequestMapping("/user/{id}") public String test(@PathVariable(& ...

  3. Spring MVC @PathVariable 特殊字符

    1.问题 SpringMVC项目中通过下面的URL进行GET请求.当version有多个小数点的时候.如version为1.0.1008.后台通过@PathVariable来获取version等于1. ...

  4. Spring MVC @PathVariable注解(3)

    下面用代码来演示@PathVariable传参方式 1 @RequestMapping("/user/{id}") 2 public String test(@PathVariab ...

  5. spring mvc中的@PathVariable(转)

    鸣谢:http://jackyrong.iteye.com/blog/2059307 ------------------------------------------------ spring m ...

  6. spring mvc:练习 @RequestParam(参数绑定到控制器)和@PathVariable(参数绑定到url模板变量)

    spring mvc:练习 @RequestParam和@PathVariable @RequestParam: 注解将请求参数绑定到你的控制器方法参数 @PathVariable: 注释将一个方法参 ...

  7. spring mvc中的@PathVariable

    spring mvc中的@PathVariable是用来获得请求url中的动态参数的,十分方便,复习下: @Controller public class TestController { @Requ ...

  8. [Java] Spring MVC 知识点

    云图: @Service 用于标注业务层组件. 在 Spring-servlet 配置xml中,component-scan 标签默认情况下自动扫描指定路径下的包(含所有子包),将带有@Compone ...

  9. Spring mvc中@RequestMapping 6个基本用法

    Spring mvc中@RequestMapping 6个基本用法 spring mvc中的@RequestMapping的用法.  1)最基本的,方法级别上应用,例如: Java代码 @Reques ...

随机推荐

  1. 转载 - AC自动机算法

    出处:http://blog.csdn.net/niushuai666/article/details/7002823 AC自动机简介:  首先简要介绍一下AC自动机:Aho-Corasick aut ...

  2. [bzoj1708][Usaco2007 Oct]Money奶牛的硬币_动态规划_背包dp

    Money奶牛的硬币 bzoj-1708 Usaco-2007 Oct 题目大意:在创立了她们自己的政权之后,奶牛们决定推广新的货币系统.在强烈的叛逆心理的驱使下,她们准备使用奇怪的面值.在传统的货币 ...

  3. android 点击返回键退出程序的方法

    android 点击返回键退出程序的方法 第一种: 再按一次返回键退出程序 private long exitTime = 0; @Override public boolean onKeyDown( ...

  4. REST当道,NO MVC

    前世今生 B/S开发经历了几个时代,如今已经是后MVC时期了. MVC体现了分层和解耦合的概念.从功能和理念上都做出过巨大贡献,使Java B/S开发在面对大型项目时从容不迫,说成是上个十年Java ...

  5. FPGA 浮点单元设计

    浮点数在内存中的存放格式例如以下: 地址 +0 +1 +2 +3 内容 SEEE EEEE EMMM MMMM MMMM MMMM MMMM MMMM 这里 S 代表符号位,1是负,0是正 E 偏移1 ...

  6. adb命令查看报名和查看手机分辨率

    打开所要查看的应用包名: $ adb shell dumpsys activity top | head -n 10 TASK com.ss.android.article.news id=5 ACT ...

  7. git的经常使用命令

    $ git config --global user.name "姓名" $ git config --global user.email "xxx@qq.com&quo ...

  8. 解决solr搜索多词匹配度和排序方案

    转载请标明出处:http://blog.csdn.net/hu948162999/article/details/47727159 本文主要介绍了在短语.句子.多词查询中.solr在控制查询命中数量. ...

  9. 《从零開始学Swift》学习笔记(Day 56)—— Swift编码规范之命名规范

    原创文章,欢迎转载.转载请注明:关东升的博客 程序代码中到处都是自定义的名字,取一个有样而且符合规范的名字非常重要. 命名方法非常多,可是比較有名的,广泛接受命名法有: 匈牙利命名,一般仅仅是命名变量 ...

  10. Uva1335 二分+贪心

    /* 奇数怎么搞呢 二分到答案怎么judge呢 贪心怎么贪呢 假设贪心方案是 前两个挨着取 后面的能靠前就靠前 这样子似乎保证了ans最min 但是不管贪的对不对 操作起来时间GG 而且 如果真的这样 ...