码迷,mamicode.com
首页 > 其他好文 > 详细

term work

时间:2015-08-03 00:54:14      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

package org.dp.course.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.dp.database.DatebaseHandler;
import org.dp.wechat.pojo.ActionInfo;
import org.dp.wechat.pojo.CreateTicket;
import org.dp.wechat.pojo.Scene;
import org.dp.wechat.pojo.Ticket;
import org.dp.wechat.util.MessageUtil;
import org.dp.wechat.util.CommonUtil;

import net.sf.json.JSONArray;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;

/**
 * loginservlet
 * 
 * @author DP
 * 
 */
public class Ew extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		// super.doGet(req, resp);
		System.out.println("=========doGet========");
		this.doPost(req, resp);

	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse response)
			throws ServletException, IOException {
		
		
              System.out.println("d d");
		
			/*Ticket ticket = CommonUtil.getTicket(
					getticket("QR_SCENE",300, 1),
					CommonUtil.gettoken());
			String tk = ticket.getTicket();
			int es = ticket.getExpire_seconds();
			String url = ticket.getUrl();
			String stUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket="
					+ java.net.URLEncoder.encode(tk);*/
              String stUrl="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQFK8DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL3kweXE0T3JscWY3UTltc3ZPMklvAAIEG9jUUgMECAcAAA%3d%3d";
			
			response.setContentType("text/xml; charset=UTF-8"); 
		     response.setCharacterEncoding("UTF-8");
		     response.setHeader("Cache-Control","no-cache"); 
		     StringBuffer sb = new StringBuffer();
		     PrintWriter out=response.getWriter();
			  sb.append("<img src=");
			 sb.append(stUrl);
			 sb.append("  height=200 width=200>");
			 out.println(sb.toString());
		     System.out.println(sb.toString());
		     out.close();
              
		
	}
	
	// 获取二维码凭证消息
	private static CreateTicket getticket(String action_name,
			int expire_seconds, int scene_id) {
		CreateTicket ct = new CreateTicket();
		ActionInfo ai = new ActionInfo();
		Scene sc = new Scene();
		sc.setScene_id(scene_id);
		ai.setScene(sc);
		ct.setAction_info(ai);
		ct.setAction_name(action_name);
		ct.setExpire_seconds(expire_seconds);
		return ct;
	}




}

  

term work

标签:

原文地址:http://www.cnblogs.com/hansongjiang/p/4697100.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!