有没有办法在RequestMapping中使用Enum值?
@RequestMapping(value = "/example",
method = RequestMethod.POST)
public final void foo(final HttpServletResponse response,
Run Code Online (Sandbox Code Playgroud)
我想使用已存储在枚举中的URL值.
但是,当我尝试将除字符串文字之外的任何内容放入其中时,我会收到编译时错误RequestMapping.
它是如何知道字符串文字和不是字符串文字的字符串之间的区别(不确定是什么叫)?
这是我尝试过但在编译时失败了:
@RequestMapping(value = FooEnum.Example.getStringValue(),
method = RequestMethod.POST)
public final void foo(final HttpServletResponse response,
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用,String.format但它不喜欢这样:
@RequestMapping(value = String.format("%s", FooEnum.Example.getStringValue()),
method = RequestMethod.POST)
public final void foo(final HttpServletResponse response,
Run Code Online (Sandbox Code Playgroud)