关于XHR的问题,新人很困惑,为什么获取不到报404

qq_28803955 2016-07-27 11:56:45

就是这样子,今天突然就获取不到了

这个是后台代码



public static String doGet(String meraccount,String sale_count)
throws ServletException, IOException {

StringBuffer resultBuffer = new StringBuffer();

try {

JSONObject obj = new JSONObject();
obj.put("meraccount",meraccount);
obj.put("method", "queryRstation");
obj.put("v", "1.0");
obj.put("sale_count", sale_count);
obj.put("timestamp", System.currentTimeMillis());
String param_key = encrypt(
URLEncoder.encode(obj.toString(), "UTF-8"),
PUBLICKEY);
String secret_key = URLEncoder.encode(
MD5(paramSort(obj)), "UTF-8");
ClientResource client = new ClientResource(
"http://222.184.1.86:8880/queryService/1.0/hts/queryRstation?param_key="
+ param_key + "&secret_key=" + secret_key
+ "&sale_count=3208000993005");


Representation representation = client.get();
InputStream is = representation.getStream();
resultBuffer.append(InputStreamTOString(is));

} catch (Exception e) {
e.printStackTrace();
}
return resultBuffer.toString();
}









/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/json");
response.setCharacterEncoding("UTF-8");
String meraccount = request.getParameter("meraccount");
String sale_count = request.getParameter("sale_count");
PrintWriter out = response.getWriter();
String jieguo =doGet(meraccount, sale_count);
out.print(jieguo);
System.out.println(jieguo);

}




这个是前台获取的



var shanghu = $("#CardNo").val();
var shoupiao = $("#PageNum").val();
var data = {
"meraccount":shanghu,
"sale_count": shoupiao,
}

var url ="servlet/BusServlet";//servlet路径
$.post(url,data,function(bbb){
var hhh = bbb;
for(var o in hhh.result){
alert(hhh.result[o].dep_station_name);
}
},"json");



再三检查过了 URL地址没有问题
...全文
517 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_28803955 2016-07-27
  • 打赏
  • 举报
回复
求救!!!!!!!!11

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧