3

I have this problem, I'm trying to put a String variable in the value attribute of @RequestMapping annotation:

private static final String PREVIEW = "/preview/anything";

...

@RequestMapping(value=PREVIEW, method=RequestMethod.POST)

Could I do this?
Thanks in advance

1 Answer 1

3

Yes you can although IMHO it's less readable. You normally define a constant if you want to use it in many places but in this case I'd prefer to see the url mapping directly over the method.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.