Skip to content

Specified MVC resource at root level not considered "under location" [SPR-12747] #17344

@spring-projects-issues

Description

@spring-projects-issues

Silvio Assunção Junior opened SPR-12747 and commented

I use now Spring 3.2.2 and I'm upgrading to 3.2.13 but I found a error on ResourceHttpRequestHandler

I configured my MVC resources example:
<mvc:resources location="/favicon.ico" mapping="/favicon.ico" cache-period="31556926"/>

When I request the favicon (http://localhost:8080/favicon.ico) I receive 404 (Not found). I debug the ResourceHttpRequestHandler and see that in this version has a method that in old version don't have "isResourceUnderLocation"

This method have a validation that I think is wrong
if (!resourcePath.startsWith(locationPath)) {
return false;
}

The correct in this case is locationPath.startsWith(resourcePath) because before this validation we have this code bellow
locationPath = (locationPath.endsWith("/") ||
!StringUtils.hasLength(locationPath) ? locationPath : locationPath + "/");


Affects: 3.2.13, 4.1.4

Backported to: 3.2.14

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions