请教spring mvc的问题,你不知道的事

Macrotea 发布于 2011/11/04 10:40
阅读 237
收藏 0
@RequestMapping(value = "showXml") 
@ResponseBody 
public UserDto showXml(String name) { 
logger.debug("name:"+name); 

UserDto userDto1=new UserDto(1,name,22); 

return userDto1; 
} 

这样能成功返回一个UserDto 序列化的xml字符串

若:
@RequestMapping(value = "showXml") 
@ResponseBody 
public List<UserDto> showXml(String name) { 

logger.debug("name:"+name); 

UserDto userDto1=new UserDto(1,name,22); 
UserDto userDto2=new UserDto(2,name+"2",22); 

List<UserDto> userDtoList=new ArrayList<UserDto>(); 
userDtoList.add(userDto1); 
userDtoList.add(userDto2); 

return userDtoList; 
} 

若返回一个list的UserDto却不能

请高人赐教

加载中
返回顶部
顶部