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