1

I am trying to set value for @RequestMapping annotation as follows: @RequestMapping(value = VALUE)

@RequestMapping(value = VALUE)
public class SomeClass {
  public final static String value = randomValue();
  public static randomValue() {
     return "some random stuff here";
  }
}

Now, I've noticed that is not legit since I got this error:

Attribute value must be constant

Can someone explain me why this is happening, please?

1 Answers1

1

Attribute value must be constant

Simply means that you can not assign a variable or some random values like VALUE for an endpoint. You should supply a constant string or multiple of it like the examples below:

@RequestMapping(value = "/value")
public class SomeClass {}

@RequestMapping("/value")
public class SomeClass {}

@RequestMapping(value = {"/value", "/"})
public class SomeClass {}   
Donato Amasa
  • 846
  • 2
  • 6
  • 22