Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法成功传递字符串值“$10.55“;作为弹簧路径变量_Java_Spring_Spring Mvc - Fatal编程技术网

Java 无法成功传递字符串值“$10.55“;作为弹簧路径变量

Java 无法成功传递字符串值“$10.55“;作为弹簧路径变量,java,spring,spring-mvc,Java,Spring,Spring Mvc,我的控制器类是 @RequestMapping(method = RequestMethod.POST, value = "/auditregistry/collectionentry/cid/{cid}/collid/{collid}/colldt/{collectiondate}/amount/{amt}") public ModelAndView saveManualCollection(@PathVariable("cid") Integer custId, @PathVariable

我的控制器类是

@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”


任何帮助都是非常感谢的,因为默认情况下,Spring MVC会将
之后的所有内容剥离,并将其视为文件扩展名(例如
/file.txt
)。这很容易解决。使用Spring MVC 3.1和Java配置:

@Configuration
class Cfg extends WebMvcConfigurationSupport {

    @Override
    public RequestMappingHandlerMapping requestMappingHandlerMapping() {
        final RequestMappingHandlerMapping mapping = super.requestMappingHandlerMapping();
        mapping.setUseSuffixPatternMatch(false);
        return mapping;
    }

}

注意调用:。

将您的RequestMapping更改为下面的

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

这里的更改是重新计算的,而不是您的请求映射中的{amt:.*}您是否尝试过调试,是$14.55,就像在Java代码中一样。您可能应该在客户端代码中转义点(.),因为添加setUseSuffixPatternMatch(false)对我不起作用,但是按照建议更新@RequestMapping会起作用。谢谢你能解释一下为什么会这样吗?谢谢