java - 无法成功将字符串值 "$10.55"作为 spring 路径变量传递

标签 java spring spring-mvc

我的 Controller 类是

@RequestMapping(method = RequestMethod.POST, value = "/auditregistry/collectionentry/cid/{cid}/collid/{collid}/colldt/{collectiondate}/amount/{amt}")

public ModelAndView saveManualCollection(@PathVariable("cid") Integer custId, @PathVariable("collid") Integer collRtId, @PathVariable("collectiondate") String dt, **@PathVariable("amt") String amount**) throws Exception 
{
    debug("amount recieving=="+amount);

我传递给 url 的值是

/auditregistry/collectionentry/cid/9991/collid/10/colldt/20120726/amount/$14.55

当我尝试打印金额时,它的打印值是“$14”而不是“$14.55”,我应该怎么做才能打印实际值“$14.55”

非常感谢任何帮助

最佳答案

将您的 RequestMapping 更改为以下

@RequestMapping(method = RequestMethod.POST, value = "/auditregistry/collectionentry/cid/{cid}/collid/{collid}/colldt/{collectiondate}/amount/{amt:.*}")

此处的更改在您的 RequestMapping 中被 {amt:.*} 替换为 {amt}

关于java - 无法成功将字符串值 "$10.55"作为 spring 路径变量传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12564164/

相关文章:

java - 为什么 JList 的 fireContentsChanged 调用会卡住整个 GUI?

java - OpenSessionInViewFilter 无法转换为 javax.servlet.Filter

java - 为什么 AngularJS 应用程序不能在不同的服务器上使用 REST 服务?

java - 如何使用 Spring PropertyPlaceholderConfigurer 从另一个属性文件调用属性文件?

java - 使用整数字段进行 Hibernate 验证

java - Apache PDFBox 找不到类 'Loader' 。为什么?

java - detachCopy 正在与 ObjectDB 一起使用 JDO 吗?

java - 在 Hazelcast Jet 处理器上使用 Hazelcast IMap

spring-mvc - Spring MVC JDBC 数据源事务管理器 : Data committed even after readonly=true

java - 限制服务器使用供内部使用