创建一个 Dynamic Web project 项目:
这个file=>new=>Dynamic Web project
打开WebContent目录
新建一个Api.jsp文件
<%@page import="org.omg.CORBA.Request"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
out.clear();
String string =request.getParameter("action");
if(string!=null){
if(string.equals("send_pass")){
out.print("{\"status\":1}");
}else if(string.equals("login")){
out.print("{\"status\":1,\"token\":\"adadadad\"}");
}else if(string.equals("upload_contacts")){
out.print("{\"status\":1}");
}else if(string.equals("timeline")){
out.print("{\"status\":1,\"page\":1,\"perpage\":20,\"items\":["+
"{\"msg\":\"haha1\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha2\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha3\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha4\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha5\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha12\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha11\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha10\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha9\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha8\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha7\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha100\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha10000\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"},"+
"{\"msg\":\"haha9\",\"phone_md5\":\"md5xxx\",\"msgid\":\"123456\"}"+
"]}");
}else if(string.equals("get_comment")){
out.print("{\"status\":1,\"page\":1,\"perpage\":20,\"items\":["+
"{\"content\":\"Fuck\",\"phone_md5\":\"md5xxx\"},"+
"{\"content\":\"Fuck1\",\"phone_md5\":\"md5xxx\"},"+
"{\"content\":\"Fuck2\",\"phone_md5\":\"md5xxx\"},"+
"{\"content\":\"Fuck3\",\"phone_md5\":\"md5xxx\"},"+
"{\"content\":\"Fuck4\",\"phone_md5\":\"md5xxx\"}"+
"],\"msgid\":\"123\"}");
}else if(string.equals("pub_comment")){
out.print("{\"status\":1}");
}else if(string.equals("publish")){
out.print("{\"status\":1}");
}
}else{
out.print("请指定action");
}
%>
自己按着开发文档写的返回格式,写完之后启动项目。
简单举几个例子:大家有问题可以留言讨论