Use the Contentnegotiatingviewresolver in the SPRINGMVC configuration file to try the parser, configured as follows
<!--respond to different view requests depending on the client--<bean class= " Org.springframework.web.servlet.view.ContentNegotiatingViewResolver "> <span style=" White-space:pre "> </span><!--set to true to ignore support for the Accept header--<property name= "Ignoreacceptheader" value= "true"/> < Property Name= "Defaultcontenttype" value= "text/html"/> <!--extension to mimetype Map--<property name= " MediaTypes "> <span style=" white-space:pre "> </span><map> <entry key=" JSON "value=" Application/json "/> <entry key=" xml "value=" Application/xml "/> </map> </property> <prop Erty name= "Favorparameter" value= "false"/> <property name= "viewresolvers" > <list> <bean class= "or G.springframework.web.servlet.view.beannameviewresolver "/> <bean class=" Org.springframework.web.servlet.view.InternalResourceViewResolver "p:prefix="/jsp/"p:suffix=". jsp "/> <bean Class= "Org.springframework.web.servlet.view.velocity. Velocitylayoutviewresolver "> <property name=" suffix "> <value>.vm</value> </PROPERTY&G
T <property name= "Datetoolattribute" > <value>dateTool</value> </property> <property Name= "Toolboxconfiglocation" > <value>/WEB-INF/vmtools/toolbox.xml</value> </property> &L T;property name= "ContentType" > <value>text/html;charset=UTF-8</value> </property> </be an> </list> </property> <property name= "Defaultviews" > <list> <!--for application/ JSON--<bean class= "Org.springframework.web.servlet.view.json.MappingJacksonJsonView"/> <!--for app Lication/xml-<!--<bean class= "Org.springframework.web.servlet.view.xml.MarshallingView" >
<span style= "White-space:pre" > </span><property name= "Marshaller" >
<span style= "White-space:pre" > </span><bean class= " Org.springframework.oxm.xstream.XStreamMarshaller "/>
</property>
<span style= "White-space:pre" > </span></bean>
</list>
</property >
</bean>
In the Viewresolvers attribute above, there are also Internalresourceviewresolver and velocitylayoutviewresolver two parsers. If the velocity template is used in the project, SPRINGMCV will choose to use Internalresourceviewresolver and ignore Velocitylayoutviewresolver, which causes render to fail ....
There are two solutions:
1. Do not use Contentnegotiatingviewresolver, configure the view resolver separately, and set order familiarity, Ensure Velocitylayoutviewresolver priority is greater than internalresourceviewresolver
2. Implement an arbitration parser similar to contentnegotiatingviewresolver.
If anything is wrong, please correct me.