【发布时间】:2013-07-23 04:53:56
【问题描述】:
我正在做一个 Spring 网络。对于控制器方法,我可以使用 RequestParam 来指示是否需要参数。例如:
@RequestMapping({"customer"})
public String surveys(HttpServletRequest request,
@RequestParam(value="id", required = false) Long id,
Map<String, Object> map)
我想使用如下的 PathVariable:
@RequestMapping({"customer/{id}"})
public String surveys(HttpServletRequest request,
@PathVariable("id") Long id,
Map<String, Object> map)
如何指示是否需要路径变量?我需要将其设为可选,因为在创建新对象时,在保存之前没有可用的关联 ID。
感谢您的帮助!
【问题讨论】:
-
我想你问的和这个问题一样stackoverflow.com/questions/4904092/…
标签: spring spring-mvc path-variables