`

Servlet 接口

    博客分类:
  • java
 
阅读更多

//------------------------------调用-----------------------------------------------

String httpStr = "http://localhost:8080/jsonServlet/Login.do?username=111&password=111";

URL url = new URL(httpStr);

InputStream ins = url.openConnection().getInputStream();

//------------------------------

public void doGet(HttpServletRequest req,HttpServletResponse resp)throws ServletException,IOException{

String username = req.getParameter("username");//用户名

String password = req.getParameter("password");//密码

if(username.equals("111")&&password.equals("111")){

JSONObject datas = new JSONObject();

JSONArray rs = new JSONArray();

JSONObject obj = new JSONObject();

obj.put("uid", "34860");

obj.put("uname", "411");

obj.put("utype", "5");

obj.put("nickname", "abcdef");

obj.put("myphoto", "http://114.112.91.109:8080/home/temp/pic2.gif");

rs.add(obj);

datas.put("result", "1");

datas.put("userinfo",rs);

String info = datas.toString();

System.out.println(info);

req.setAttribute("info", info);

req.getRequestDispatcher("text.jsp").forward(req,resp);

}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics