As I am new to Spring MVC framework and trying to learn, but an exception is thrown. What could be the cause?
It seems like I have an error in my dispatcher-servlet.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<annotation-driven />
<context:component-scan base-package="kz.controller" />
<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>
</beans:beans>
My controller classes are annotation driven, but it is throwing this error:
HTTP Status 500 –
Servlet.init()for servlet dispatcher threw exceptiontype Exception report
message
Servlet.init()for servlet dispatcher threw exceptiondescription The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException:Servlet.init()for servlet dispatcher threw exception
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 23 in XML document fromServletContextresource [/WEB-INF/dispatcher-servlet.xml] is invalid;
Your XML is incorrect. You defined the bean namespace under the beans namespace. The correct XML is like this:
Usually in spring applications the beans schema is the default so it would be even better if you would change the beans schema to be the default then you can delete all the “beans:” and add “mvc:” to the other tags.