Skip to content

就是不序列化。, 怎么搞都不行。。。

zhump edited this page Oct 13, 2014 · 3 revisions

1. *

@ResponseBody @RequestMapping(value = "/findByCity.json") public List findByCity() { return this.getDAO().selectList("UserMapper.getAllUser", null, new PageBounds(1, 20)); } ##

<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -→ <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -→ <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -→ </list> </property> </bean> <mvc:annotation-driven> <mvc:message-converters register-defaults="true"> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <constructor-arg value="UTF-8" /> </bean> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="objectMapper"> <bean class="com.github.miemiedev.mybatis.paginator.jackson2.PageListJsonMapper" /> </property> </bean> </mvc:message-converters> </mvc:annotation-driven> ` ` <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-core-asl</artifactId> <version>1.9.2</version> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.1.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.1.4</version> <scope>provided</scope> </dependency>

` <plugins> <plugin interceptor="com.github.miemiedev.mybatis.paginator.OffsetLimitInterceptor"> <property name="dialectClass" value="com.github.miemiedev.mybatis.paginator.dialect.MySQLDialect"/> </plugin> </plugins> `

页面展示的是

[-{"id":106,"username":"6","age":6,"password":"6"},{"id":107,"username":"6","age":6,"password":"6"},{"id":108,"username":"6","age":6,"password":"6"},{"id":109,"username":"6","age":6,"password":"6"},{"id":110,"username":"6","age":6,"password":"6"},{"id":111,"username":"6","age":6,"password":"6"},{"id":112,"username":"6","age":6,"password":"6"},{"id":113,"username":"6","age":6,"password":"6"},{"id":114,"username":"6","age":6,"password":"6"},{"id":115,"username":"6","age":6,"password":"6"},{"id":116,"username":"6","age":6,"password":"6"},{"id":117,"username":"6","age":6,"password":"6"},{"id":118,"username":"6","age":6,"password":"6"},{"id":119,"username":"6","age":6,"password":"6"},{"id":120,"username":"6","age":6,"password":"6"},{"id":121,"username":"6","age":6,"password":"6"},{"id":122,"username":"6","age":6,"password":"6"},{"id":123,"username":"6","age":6,"password":"6"},{"id":124,"username":"6","age":6,"password":"6"},{"id":125,"username":"6","age":6,"password":"6"}-]

不是我想要的 { "items":[ {"NAME":"xiaoma","AGE":30,"GENDER":1,"ID":3,"CITY":"BeiJing"}, {"NAME":"xiaoli","AGE":30,"SCORE":85,"GENDER":1,"ID":1,"CITY":"BeiJing"}, {"NAME":"xiaowang","AGE":30,"SCORE":92,"GENDER":0,"ID":2,"CITY":"BeiJing"}, {"NAME":"xiaoshao","AGE":30,"SCORE":99,"GENDER":0,"ID":4,"CITY":"BeiJing"} ], "slider": [1, 2, 3, 4, 5, 6, 7], "hasPrePage": false, "startRow": 1, "offset": 0, "lastPage": false, "prePage": 1, "hasNextPage": true, "nextPage": 2, "endRow": 30, "totalCount": 40351, "firstPage": true, "totalPages": 1346, "limit": 30, "page": 1 }

晕 这代码 怎么挑整洁啊。。。搞不好了。。。。。

大大 帮我看看我怎么让json序列化和你一样啊。。。。

Clone this wiki locally