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

最新文章

  1. .Net语言 APP开发平台——Smobiler学习日志:Poplist控件的正确打开方式以及如何快速实现
  2. Zabbix3.x安装图解教程
  3. transform-style: preserve-3d在iphone下的bug
  4. JavaScript-在当前显示区范围内实现点不到的小方块
  5. Redhat5.8 环境下编译安装 Redis 并将其注册为系统服务
  6. 使用php作linux自动执行脚本
  7. 关于JS中的apply()与call()使用方法与区别
  8. javascript时钟
  9. android Json解析详解(详细代码)
  10. C# 串口接收数据中serialPort.close()死锁
  11. R语言︱决策树族——随机森林算法
  12. git reset揭秘
  13. ElasticSearch(八):elasticsearch.yml配置说明
  14. python3简单实现微信爬虫
  15. 使用SQL语句创建数据库2——创建多个数据库文件和多个日志文件
  16. 使用 scm-manager 搭建 git/svn 代码管理仓库(二)
  17. 【笔记】JS脚本为什么要放在body最后面以及async和defer的异同点
  18. flask第十七篇——模板【1】
  19. 用c++读取文件夹中的所有文件名
  20. 如何在PB中调用 Microsoft WEB 浏览器 控件?

热门文章

  1. STL之rb_tree的find函数
  2. HDU 4518
  3. POJ 1198/HDU 1401
  4. 【MongoDB】windows平台搭建Mongo数据库复制集(相似集群)(三)
  5. 设计模式C++实现——组合模式
  6. Problem G 宝石合成 (内蒙古14年省赛)
  7. 【Cocos2dx】资源目录,播放背景音乐,导入外部库
  8. C#实现动态调用Windows DLL
  9. Visio的安装教程
  10. 超级简单的利用javascript实现文件拖拽事件