Reputation: 2404
I applied spring validation in my registration page .but the follwing error are shown in my server log of my app engine server.
javax.servlet.UnavailableException:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 22 in XML document from ServletContext resource
[/WEB-INF/spring/appServlet/servlet-context.xml] is invalid;
nested exception is org.xml.sax.SAXParseException;
lineNumber: 22; columnNumber: 30;
cvc-complex-type.2.4.c: The matching wildcard is strict,
but no declaration can be found for element 'property'.
My code is given below :
<?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
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd >
<beans:bean name="/register" class="com.my.registration.NewUserRegistration">
<property name="validator">
<bean class="com.my.validation.UserValidator" />
</property>
<beans:property name="formView" value="newuser"></beans:property>
<beans:property name="successView" value="home"></beans:property>
</beans:bean>
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
</beans:beans>
Upvotes: 2
Views: 3640
Reputation: 242736
Default XML namespace of your document is http://www.springframework.org/schema/mvc
, therefore you should use namespace prefix for all elements from other namespaces, including elements from http://www.springframework.org/schema/beans
namespace:
<beans:property name="validator">
<beans:bean class="com.my.validation.UserValidator" />
</beans:property>
Alternatively, you can configure http://www.springframework.org/schema/beans
as a default namespace:
xmlns = "http://www.springframework.org/schema/beans"
Obviously, in this case you'd need to use namespace prefix for elemetns from mvc
namespace, if you have any.
See also:
Upvotes: 1
Reputation:
This does not have the propery XML namespace prefix:
<property name="validator">
<bean class="com.my.validation.UserValidator" />
</property>
Use beans
as the prefix.
Actually I recommend to use the beans
namespace as the default XML namespace and to make mvc
an explicit namespace.
Upvotes: 1