spring responseBody not work in IE

imadma

New Member
I'm trying to use responseBody annotation to return xml in controller.Every browser works fine except IE(I'm using IE 9 in windows 7 x64). I found that it will request several times and then failed in request.Hope some of you haved encounter this and offer some help.My code as followed:UserController.java.This is just a simple controller,returning an object that represent User. package com.spring;\[code\]import javax.xml.bind.annotation.XmlElement;import javax.xml.bind.annotation.XmlRootElement;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;@Controllerpublic class UserController {@RequestMapping("/user")public @ResponseBody User getUser(){ User user = new User(); user.setName("shun"); user.setPassword("123123"); return user;}}@XmlRootElement(name="user")class User {private String name;private String password;@XmlElementpublic String getName() { return name;}public void setName(String name) { this.name = name;}@XmlElementpublic String getPassword() { return password;}public void setPassword(String password) { this.password = password;}}\[/code\]web.xml:\[code\]<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"><servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup></servlet><servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/</url-pattern></servlet-mapping><welcome-file-list> <welcome-file>index.jsp</welcome-file></welcome-file-list></web-app>\[/code\]I used spring-servlet.xml as my spring configuration file.As following:\[code\]<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"><mvc:annotation-driven /><context:annotation-config /><context:component-scan base-package="com.spring" /><bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="mediaTypes"> <map> <entry key="xml" value="http://stackoverflow.com/questions/12576031/application/xml" /> <entry key="json" value="http://stackoverflow.com/questions/12576031/application/json" /> <entry key="jsonp" value="http://stackoverflow.com/questions/12576031/application/javascript" /> </map> </property> <property name="defaultContentType" value="http://stackoverflow.com/questions/12576031/text/html" /> <property name="ignoreAcceptHeader" value="http://stackoverflow.com/questions/12576031/true" /> <property name="favorPathExtension" value="http://stackoverflow.com/questions/12576031/true" /> <property name="favorParameter" value="http://stackoverflow.com/questions/12576031/true" /> <property name="parameterName" value="http://stackoverflow.com/questions/12576031/return_fmt"></property> <property name="viewResolvers"> <list> <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" /> </list> </property> <property name="defaultViews"> <list> <bean class="org.springframework.web.servlet.view.xml.MarshallingView"> <property name="marshaller"> <ref bean="castorMarshaller"/> </property> </bean> <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" /> </list> </property></bean><bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller" />\[/code\]By the way, my spring version is 3.1.0.And I also used 3.0.7 for test,just the same result.After I started my project,I use chrome,firefox to visit it ,everything is fine.But When I try visiting it in IE 9,it shows me this result.Is anyone can tell me what happened?Thank you!
 
Back
Top