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/" />
5
  • 1
    Can you show the content of your dispatcher-servlet.xml file here? Commented Sep 22, 2012 at 10:10
  • <mvc:annotation-driven /> <mvc:resources mapping="/res/**" location="/admin/" /> Commented Sep 22, 2012 at 12:17
  • can you post the dispatcher-servlet in your question? The full xml file. Commented Sep 23, 2012 at 9:32
  • Please show the full content of the dispatcher-servlet.xml file. Including the schema definations. Commented Sep 24, 2012 at 5:10
  • Since i dont have more reputation, am not able paste whole xml. my dispatcher-servlet.xml is similar like this stackoverflow.com/questions/9816642/spring-mvc-url-mapping Commented Sep 24, 2012 at 6:52

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.