如何使用<;在Spring3配置文件中指定模式验证;oxm:jaxb2-marshaller>;元素?
我选择在我的项目中使用Spring Jaxb2Marshaller来支持JAXB,但我无法在元素如何使用<;在Spring3配置文件中指定模式验证;oxm:jaxb2-marshaller>;元素?,spring,jaxb,Spring,Jaxb,我选择在我的项目中使用Spring Jaxb2Marshaller来支持JAXB,但我无法在元素oxm:jaxb2 marshaller中指定模式文件,我只找到了一个contextPath属性,没有找到任何关于模式的内容 我必须使用旧的Jaxb2Marshaller配置样式(使用bean:bean元素) 类Jaxb2Marshaller具有模式属性,请尝试此代码示例 <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.
oxm:jaxb2 marshaller
中指定模式文件,我只找到了一个contextPath属性,没有找到任何关于模式的内容
我必须使用旧的Jaxb2Marshaller配置样式(使用
bean:bean
元素) 类Jaxb2Marshaller
具有模式属性,请尝试此代码示例
<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>my.package.ResponseObj</value>
</list>
</property>
<!-- Possibly include schema for validation -->
<property name="schema" value="classpath:schema.xsd"/>
</bean>
my.package.ResponseObj
编辑:
我认为您不能使用新的OXM应答器在配置文件中直接指定XML模式。中没有用于此的xml元素或属性。但是您可以直接在“classe to bind”中使用新的@XmlSchema注释。看看这个。类
Jaxb2Marshaller
有一个schema属性,请尝试下面的代码示例
<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>my.package.ResponseObj</value>
</list>
</property>
<!-- Possibly include schema for validation -->
<property name="schema" value="classpath:schema.xsd"/>
</bean>
my.package.ResponseObj
编辑:
我认为您不能使用新的OXM应答器在配置文件中直接指定XML模式。中没有用于此的xml元素或属性。但是您可以直接在“classe to bind”中使用新的@XmlSchema注释。看看这个。谢谢,您的解决方案非常好,但我想要的是oxm:jaxb2 marshaller配置样式,而不是旧样式。我在oxm:jaxb2-marshaller元素中找不到任何schema-config属性。谢谢,您的解决方案非常好,但我想要的是oxm:jaxb2-marshaller配置样式,而不是旧样式。我在oxm:jaxb2 marshaller元素中找不到任何schema-config属性。