我是MVC的新手,并且一直在尝试从对象列表生成一个表,但是ajax调用仍然失败。难道我做错了什么 ? 以下是我的控制器代码
@RequestMapping(value="/PopulateTable",method = RequestMethod.GET,headers="Accept=*/*")
public @ResponseBody ArrayList<ReportMetrics> doGet(HttpServletRequest
request, HttpServletResponse response) throws ServletException,
IOException {
ArrayList<ReportMetrics> metrics=new ArrayList<ReportMetrics>();
metrics=responseservice.getReportMetrics();;
return metrics;
}
我的Jquery代码是
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#showTable").click(function(){
$("div").css("border", "3px solid blue");
$("div").css("border", "3px solid gray");
$.ajax({
type: "GET",
url: "/PopulateTable",
success: function(data,status)
{
createTableByForLoop(data);
createTableByJqueryEach(data);
},
async: true,
dataType: 'json'
});
});
});
已经具有以下依赖性
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
我在web.xml上的URI映射
<servlet-mapping>
<servlet-name>SplunkPOC</servlet-name>
<url-pattern>*.htm</url-pattern>
<url-pattern>*.*</url-pattern>
</servlet-mapping>