ajax读取json显示undefined
xml:
<!-- 启动JSON格式的配置 -->
<bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes">
<list><value>text/html;charset=UTF-8</value></list>
</property>
</bean>
Dao层:
public List<DepotWarn> getPageDepotWarn(DepotWarn depotWarn,int pageNum,int pageSize){
int num=(pageNum-1)*pageSize>=0?(pageNum-1)*pageSize:0;
return getSqlMapClientTemplate().queryForList("selectWarn", depotWarn, num, pageSize);
}
Controller层:
@RequestMapping("/depotWarnlistajax")
public @ResponseBody List<DepotWarn> listPositionDo(Model model,
@RequestParam(value = "pagesize", required = false, defaultValue = "1") int pagesize,
@RequestParam(value = "pagenum", required = false, defaultValue = "1") int pagenum){
System.out.println("***listPositionDo***");
List<DepotWarn> ret = depotWarnService.getPageDepotWarn(null, pagenum, pagesize);
return ret;
}
jsp页面:
function AjaxGetData(index, size) {
$.ajax({
url: "<%=basePath%>Inventory/depotWarnlistajax",
type: "get",
data: "pagenum=" + index + "&pagesize=" + size,
dataType: "json",
ontentType: "application/JSON",
success: function (warns) {
alert(warns);
var html = "";