Use or not leading slash in value for @RequestMapping. Need official docs or point to Spring source?

It does not matter: If the path does not start with an / then Spring (DefaultAnnotationHandlerMapping) will add it.

See method String[] determineUrlsForHandler(String beanName) of Class DefaultAnnotationHandlerMapping line 122 (Spring 3.1.2) (that is for the class level)

String[] methodLevelPatterns = determineUrlsForHandlerMethods(handlerType, true);
for (String typeLevelPattern : typeLevelPatterns) {
    if (!typeLevelPattern.startsWith("https://stackoverflow.com/")) {
            typeLevelPattern = "https://stackoverflow.com/" + typeLevelPattern;
    }

See method String[] determineUrlsForHandler(Class<?> handlerType, final boolean hasTypeLevelMapping)) of Class DefaultAnnotationHandlerMapping line 182 (Spring 3.1.2) (that is for the method level)

String[] mappedPatterns = mapping.value();
if (mappedPatterns.length > 0) {
for (String mappedPattern : mappedPatterns) {
    if (!hasTypeLevelMapping && !mappedPattern.startsWith("https://stackoverflow.com/")) {
        mappedPattern = "https://stackoverflow.com/" + mappedPattern;
    }   

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)