我的 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/