日期:2014-05-16  浏览次数:20659 次

struts jquery ajax 老是进入error方法
本帖最后由 showbo 于 2012-09-28 09:30:21 编辑
跪求大仙指导!!!
index.js
$("#aaa").click(function (){
alert("0000================");
$.ajax({
url:'http://localhost:8080/Public_Bicycle_System/allSite.action',
type:'post',
data:'',
dataType:'json',
success:function(msg){
$(msg.bicycleSites).each(function(i,value){
alert(+"==========");
/*var point = new BMap.Point(value.lat_Long.x, value.lat_Long.y);
var marker = new BMap.Marker(point);
map.addOverlay(marker); */
}
);
},
error:function(mm){
alert("message error");
ob=eval(mm);
var pro = "";
for(var i in ob){
pro+=i+"\n";
}
alert(pro);
alert(mm.getAllResponseHeaders);
}});
});

index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="initial-scale=1.0,user-scalable=no"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Insert title here</title>
<link href="file/css/index.css" rel="stylesheet" type="text/css">
<script src="file/javascript/jquery/jquery.min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>

</head>
<body>
<div id="title">
<input type="button" id="aaa" value="sfsffs"/>
</div>

struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>

    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="true" />

    <package name="default" namespace="/" extends="json-default">

<!-- 当页面刚加载时用ajax请求 -->
        <action name="allSite" class="com.pbs.action.BicycleSiteAction">
      <result name="users" type="json"></result>
        </action>        <action name="allSite" class="com.pbs.action.BicycleSiteAction">
      <result name="users">/success.jsp</result>
        </action>
    </package>
</struts>

BicycleSiteAction.java
package com.pbs.action;

import java.util.List;

import org.apache.struts2.json.annotations.JSON;

import com.opensymphony.xwork2.ActionSupport;
import com.pbs.model.BicycleSite;
import com.pbs.service.BicycleSiteService;
import com.pbs.se