0

I need to map my URL in spring mvc as

www.xyz.com\admin\addproduct, www.xyz.com\admin\usermanagement, www.xyz.com\admin\report,

I tried in my web.xml as

<url-pattern>/</url-pattern>

I also read previous article about this Spring MVC url-mapping

but when i add mvc resource in dispatcher-servlet.xml file i got the following error

Multiple annotations found at this line: - Configuration problem: Cannot locate BeanDefinitionParser for element [resources] Offending resource: file [D:/STS-3.0-Workspace/Sale365/WebContent/WEB-INF/dispatcher-
servlet.xml] - Cannot locate BeanDefinitionParser for element [resources]

dispatcher-servlet.xml

<context:component-scan base-package="com.company" />
    <bean id="viewResolver"
         class="org.springframework.web.servlet.view.UrlBasedViewResolver">
         <property name="viewClass"
             value="org.springframework.web.servlet.view.JstlView" />
         <property name="prefix" value="/WEB-INF/jsp/" />
         <property name="suffix" value=".jsp" />
     </bean>
     <mvc:annotation-driven />   <mvc:resources mapping="/res/**" location="/admin/" />
Community
  • 1
  • 1
Anand
  • 339
  • 4
  • 5
  • 16

1 Answers1

0

You should not map your resource/** to same URL that you map in Spring controller.

In controller, you are mapping /admin/usermanagement, /admin/report to spring methods and at same time defining resources to /admin/ path.

Change:

<mvc:resources mapping="/res/**" location="/admin/" />

to other path where your static resources are stored.. For example /WebContent/resources

<mvc:resources mapping="/res/**" location="/resources/" />

Let me know if that works.

Viral Patel
  • 8,506
  • 3
  • 32
  • 29