OneTwo
OneTwo

Reputation: 2483

Mapping resources with Spring MVC

I first setup Spring MVC to handle all urls.

<servlet-mapping>
    <servlet-name>HelloWeb</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

And the dispatcher servlet mapped resources.

<mvc:resources mapping="/resources/**" location="/VAADIN/resource/" />

This worked fine, but now I want to change Spring so that it only handle's '/search/' URLs.

<servlet-mapping>
    <servlet-name>HelloWeb</servlet-name>
    <url-pattern>/search/*</url-pattern>
</servlet-mapping>

This works but my resources no longer work. I think it's because it's looking for the resources in /search/resources rather than /resources. But I'm not sure.

Anyone have any idea why this is happening?

Thanks!

Upvotes: 1

Views: 150

Answers (1)

Santhosh
Santhosh

Reputation: 8187

You can make your static resources visible , configure the static resources in your web.xml.

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/VAADIN/resource/*</url-pattern>
</servlet-mapping>

If VAADIN is the project name , need not specify it here

Upvotes: 1

Related Questions