??xml version="1.0" encoding="utf-8" standalone="yes"?>青青草视频在线观看,中文字幕综合,一区二区三区在线免费观看http://www.aygfsteel.com/resteater/category/54708.html随心而动zh-cnSat, 12 Sep 2015 05:09:48 GMTSat, 12 Sep 2015 05:09:48 GMT60微信现金U包开?QJAVAQ?/title><link>http://www.aygfsteel.com/resteater/archive/2015/09/11/427271.html</link><dc:creator>休息食客</dc:creator><author>休息食客</author><pubDate>Fri, 11 Sep 2015 07:46:00 GMT</pubDate><guid>http://www.aygfsteel.com/resteater/archive/2015/09/11/427271.html</guid><wfw:comment>http://www.aygfsteel.com/resteater/comments/427271.html</wfw:comment><comments>http://www.aygfsteel.com/resteater/archive/2015/09/11/427271.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/resteater/comments/commentRss/427271.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/resteater/services/trackbacks/427271.html</trackback:ping><description><![CDATA[<span style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">W一节讲了怎么准备所有的参数Q这里讲怎么这些参数组成xmlQ即要通过HTTPS发送的数据Q?/span><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">大家可以先在|上了解一下java bean转xml的相关知?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">1、我Z里一个请求参数类</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">public class WechatCashHongbaoSendReq {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private String nonce_str;             //随机字符?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private String sign;                  //{֐</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private String mch_billno;            //商户订单?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private String mch_id;                //商户?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private String wxappid;               //公众账号appid</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private String send_name;             //商户名称</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private String re_openid;             //用户openid</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private int total_amount;          //付款金额</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private int total_num;             //U包发放Mh?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private String wishing;               //U包福?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private String client_ip;             //Ip地址</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private String act_name;              //zd名称</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private String remark;                //备注</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public String getNonce_str() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return nonce_str;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setNonce_str(String nonce_str) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.nonce_str = nonce_str;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public String getSign() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return sign;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setSign(String sign) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.sign = sign;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public String getMch_billno() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return mch_billno;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setMch_billno(String mch_billno) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.mch_billno = mch_billno;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public String getMch_id() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return mch_id;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setMch_id(String mch_id) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.mch_id = mch_id;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public String getWxappid() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return wxappid;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setWxappid(String wxappid) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.wxappid = wxappid;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public String getSend_name() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return send_name;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setSend_name(String send_name) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.send_name = send_name;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public String getRe_openid() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return re_openid;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setRe_openid(String re_openid) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.re_openid = re_openid;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public int getTotal_amount() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return total_amount;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setTotal_amount(int total_amount) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.total_amount = total_amount;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public int getTotal_num() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return total_num;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setTotal_num(int total_num) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.total_num = total_num;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public String getWishing() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return wishing;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setWishing(String wishing) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.wishing = wishing;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public String getClient_ip() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return client_ip;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setClient_ip(String client_ip) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.client_ip = client_ip;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public String getAct_name() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return act_name;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setAct_name(String act_name) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.act_name = act_name;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public String getRemark() {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  return remark;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> public void setRemark(String remark) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  this.remark = remark;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">}</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"><span style="background-color: inherit; line-height: 1.5;"><br style="background-color: inherit;" /></span></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"><span style="background-color: inherit; line-height: 1.5;">2、然后把13个参数都setq去</span></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">WechatCashHongbaoSendReq sendReq = new WechatCashHongbaoSendReq();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setNonce_str(nonce_str);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setSign(sign);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setMch_billno(mch_billno);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setMch_id(mch_id);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setWxappid(wxappid);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setSend_name(send_name);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setRe_openid(re_openid);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setTotal_amount(total_amount);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setTotal_num(total_num);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setWishing(wishing);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setClient_ip(client_ip);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setAct_name(act_name);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  sendReq.setRemark(remark);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">3、将hc{为xml</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">String data = Util.bean2XML(req).replaceAll("__", "_");    //Z么要加一个replaceAll("__", "_"),如果不加Q会有什么情况,大家可以试试</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">写一个Utilc,代码如下Q?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">import com.thoughtworks.xstream.XStream;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">import com.thoughtworks.xstream.core.util.QuickWriter;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">import com.thoughtworks.xstream.io.HierarchicalStreamWriter;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">import com.thoughtworks.xstream.io.xml.XppDriver;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">import java.io.*;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">import java.lang.reflect.Field;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">import java.util.Map;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">/**</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> * User: rizenguo</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> * Date: 2014/10/23</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> * Time: 14:59</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> */</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">public class Util {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    //打log?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    /**</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * 通过反射的方式遍历对象的属性和属性|方便调试</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     *</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * @param o 要遍历的对象</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * @throws Exception</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     */</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    public static void reflect(Object o) throws Exception {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        Class cls = o.getClass();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        Field[] fields = cls.getDeclaredFields();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        for (int i = 0; i < fields.length; i++) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            Field f = fields[i];</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            f.setAccessible(true);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            Util.log(f.getName() + " -> " + f.get(o));</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    public static byte[] readInput(InputStream in) throws IOException {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        ByteArrayOutputStream out = new ByteArrayOutputStream();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        int len = 0;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        byte[] buffer = new byte[1024];</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        while ((len = in.read(buffer)) > 0) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            out.write(buffer, 0, len);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        out.close();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        in.close();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        return out.toByteArray();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    public static String inputStreamToString(InputStream is) throws IOException {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        ByteArrayOutputStream baos = new ByteArrayOutputStream();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        int i;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        while ((i = is.read()) != -1) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            baos.write(i);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        return baos.toString();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    public static InputStream getStringStream(String sInputString) throws UnsupportedEncodingException {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        ByteArrayInputStream tInputStringStream = null;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        if (sInputString != null && !sInputString.trim().equals("")) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            tInputStringStream = new ByteArrayInputStream(sInputString.getBytes("UTF-8"));</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        return tInputStringStream;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    public static Object getObjectFromXML(String xml, Class tClass) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        //从APIq回的XML数据映射到Java对象</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     xstream.alias("xml", tClass);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        return xstream.fromXML(xml);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    public static String getStringFromMap(Map<String, Object> map, String key, String defaultValue) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        if (key == "" || key == null) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            return defaultValue;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        String result = (String) map.get(key);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        if (result == null) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            return defaultValue;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        } else {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            return result;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    public static int getIntFromMap(Map<String, Object> map, String key) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        if (key == "" || key == null) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            return 0;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        if (map.get(key) == null) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            return 0;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        return Integer.parseInt((String) map.get(key));</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    /**</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * 打log接口</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * @param log 要打印的log字符?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * @return q回log</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     */</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    public static String log(Object log){</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        return log.toString();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    /**</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * d本地的xml数据Q一般用来自用</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * @param localPath 本地xml文g路径</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * @return d的xml字符?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     */</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    public static String getLocalXMLString(String localPath) throws IOException {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        return Util.inputStreamToString(Util.class.getResourceAsStream(localPath));</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">   </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    /**</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * java对象转ؓxml字符?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * @param clazz</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * @return</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     */</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    public static String bean2XML(Object o){</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     xstream.alias("xml", o.getClass());</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     return xstream.toXML(o);</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">   </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    /**</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  * 扩展xstreamQ其支持CDATA?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  *  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  * @date 2013-05-19</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">  */  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> private static XStream xstream = new XStream(new XppDriver() {  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     public HierarchicalStreamWriter createWriter(Writer out) {  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">         return new PrettyPrintWriter(out) {  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">             // Ҏ有xml节点的{换都增加CDATA标记  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">             boolean cdata = true;  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">   </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">             @SuppressWarnings("unchecked")  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">             public void startNode(String name, Class clazz) {  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">                 super.startNode(name, clazz);  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">             }  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">   </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">             protected void writeText(QuickWriter writer, String text) {  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">                 if (cdata) {  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">                     writer.write("<![CDATA[");  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">                     writer.write(text);  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">                     writer.write("]]>");  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">                 } else {  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">                     writer.write(text);  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">                 }  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">             }  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">         };  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     }  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> });  </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">   </div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">}</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">到这一步,已经完成了最l要发送出ȝ数据Q然后是写httphҎ?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">声明Q工L代码参考微信支付开发的demoQ有些自己做了小改动?/span></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">PS:需要引入xstream-1.3.1.jar包,大家可以去apache中央仓库?a style="cursor: pointer;">https://repository.sonatype.org</a>Q输入xstream可以搜索到Qƈ下蝲出来Q如果你的项目是maven建立的,直接在pom.xml里面加上p</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"><dependency></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     <groupId>com.thoughtworks.xstream</groupId></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     <artifactId>xstream</artifactId></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     <version>1.3.1</version></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></dependency></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><img src ="http://www.aygfsteel.com/resteater/aggbug/427271.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/resteater/" target="_blank">休息食客</a> 2015-09-11 15:46 <a href="http://www.aygfsteel.com/resteater/archive/2015/09/11/427271.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>微信现金U包开?QJAVAQ?/title><link>http://www.aygfsteel.com/resteater/archive/2015/09/10/427248.html</link><dc:creator>休息食客</dc:creator><author>休息食客</author><pubDate>Thu, 10 Sep 2015 07:35:00 GMT</pubDate><guid>http://www.aygfsteel.com/resteater/archive/2015/09/10/427248.html</guid><wfw:comment>http://www.aygfsteel.com/resteater/comments/427248.html</wfw:comment><comments>http://www.aygfsteel.com/resteater/archive/2015/09/10/427248.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/resteater/comments/commentRss/427248.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/resteater/services/trackbacks/427248.html</trackback:ping><description><![CDATA[<span style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">开发之前,最好有一些微信开发的l验Q先看一下文档,了解一?/span><a style="cursor: pointer; font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">https://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_5</a><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">文档q了一遍之后,脑v里应该有些印象了Q废话不_q入开发?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">准备参数Q一个一个来?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">参数1Q随机字W串    <span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">nonce_str</span><br style="background-color: inherit;" /><div style="background-color: inherit;"></div></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">//获取随机?q里讑֮长度20,只要不成长于32?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">String nonce_str = RandomStringGenerator.getRandomStringByLength(20); </span></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"><br style="background-color: inherit;" /></span></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">写一个RandomStringGeneratorc,写一个getRandomStringByLength静态方?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">import java.util.Random;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">/**</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> * User: rizenguo</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> * Date: 2014/10/29</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"> */</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">public class RandomStringGenerator {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    /**</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * 获取一定长度的随机字符?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * @param length 指定字符串长?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     * @return 一定长度的字符?/div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">     */</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    public static String getRandomStringByLength(int length) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        String base = "abcdefghijklmnopqrstuvwxyz0123456789";</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        Random random = new Random();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        StringBuffer sb = new StringBuffer();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        for (int i = 0; i < length; i++) {</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            int number = random.nextInt(base.length());</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">            sb.append(base.charAt(number));</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">        return sb.toString();</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">    }</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">}</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"></div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">参数2 Q?nbsp;商户?  mch_id</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;">String mch_id = “xxxxxxxx”;</div><div style="font-family: 微Y雅黑; widows: auto; background-color: #ffffff;"><div style="background-color: inherit;"><img src="file:///C:/Documents%20and%20Settings/lb/Local%20Settings/Application%20Data/YNote/data/tclobbyer@163.com/ee8fd967b8764c46a330ebc1c59424ff/j%25sbr5%5Bm40nw.png" data-media-type="image" data-attr-org-src-id="91F0A2992DFC4197A82799ADEEE8812B" data-attr-org-img-file="file:///C:/Documents%20and%20Settings/lb/Local%20Settings/Application%20Data/YNote/data/tclobbyer@163.com/ee8fd967b8764c46a330ebc1c59424ff/j%25sbr5%5Bm40nw.png" style="background-color: inherit; cursor: default; display: inline-block; margin-top: 8px; max-width: 800px;" alt="" /></div><div style="background-color: inherit;"></div><div style="background-color: inherit;"><img src="http://www.aygfsteel.com/images/blogjava_net/resteater/QQ囄20150910153338.png" width="768" height="653" alt="" /></div><div style="background-color: inherit;"><br />参数3 Q?nbsp;<span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">商户订单? mch_billno</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"><br style="background-color: inherit;" /></span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">String mch_billno = mch_id + GenerateSequenceUtil.generateSequenceNo();</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"><br style="background-color: inherit;" /></span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">些一个GenerateSequenceUtilc,写一个generateSequenceNoҎ</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"><br style="background-color: inherit;" /></span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">import java.text.DecimalFormat;</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">import java.text.FieldPosition;</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">import java.text.Format;</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">import java.text.NumberFormat;</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">import java.text.SimpleDateFormat;</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">import java.util.Calendar;</span></div><div style="background-color: inherit;"> </div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">import org.apache.log4j.Logger;</span></div><div style="background-color: inherit;"> </div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">public class GenerateSequenceUtil {</span></div><div style="background-color: inherit;"> </div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> /** .log */</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> private static final Logger logger = Logger.getLogger(GenerateSequenceUtil.class);</span></div><div style="background-color: inherit;"> </div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> /** The FieldPosition. */</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> private static final FieldPosition HELPER_POSITION = new FieldPosition(0);</span></div><div style="background-color: inherit;"> </div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> /** This Format for format the data to special format. */</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> private final static Format dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");</span></div><div style="background-color: inherit;"> </div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> /** This Format for format the number to special format. */</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> private final static NumberFormat numberFormat = new DecimalFormat("0000");</span></div><div style="background-color: inherit;"> </div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> /** This int is the sequence number ,the default value is 0. */</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> private static int seq = 0;</span></div><div style="background-color: inherit;"> </div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> private static final int MAX = 9999;</span></div><div style="background-color: inherit;"> </div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> /**</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> * 旉格式生成序列</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> * @return String</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> */</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> public static synchronized String generateSequenceNo() {</span></div><div style="background-color: inherit;"> </div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">  Calendar rightNow = Calendar.getInstance();</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">   </span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">  StringBuffer sb = new StringBuffer();</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">   </span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">  dateFormat.format(rightNow.getTime(), sb, HELPER_POSITION);</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">   </span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">  numberFormat.format(seq, sb, HELPER_POSITION);</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">   </span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">  if (seq == MAX) {</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">   seq = 0;</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">  } else {</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">   seq++;</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">  }</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">   </span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">  logger.info("THE SQUENCE IS :" + sb.toString());</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">   </span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">  return sb.toString();</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"> }</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"><br style="background-color: inherit;" /></span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">参数4Q?nbsp;公众账号appid   wxappid</span></div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;"><br style="background-color: inherit;" /></span></div><div style="background-color: inherit;">q个参数可以在微信开发者中心里面看?/div><div style="background-color: inherit;"><span style="color: #222222; font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', 黑体, Arial, sans-serif;">//微信分配的公众̎号ID</span></div><div style="background-color: inherit;">String wxappid = "wx8888888888888888";</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">参数5 Q?nbsp;商户名称   send_name</div><div style="background-color: inherit;">随便?/div><div style="background-color: inherit;">String send_name = "试?;   </div><div style="background-color: inherit;"></div><div style="background-color: inherit;">参数6 Q?nbsp;用户openid   re_openid</div><div style="background-color: inherit;">微信号和公众号对应的唯一的加密过的字W串</div><div style="background-color: inherit;">String re_openid = "xxxxxxxxxxxxxxxxxxxxxxx";</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">参数7Q?nbsp;付款金额   total_amount</div><div style="background-color: inherit;">int total_amount = 100;    单位?/div><div style="background-color: inherit;"></div><div style="background-color: inherit;">参数8 Q?nbsp;U包发放Mh? total_num</div><div style="background-color: inherit;">int total_num = 1;</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">参数9 Q?nbsp;U包福?  wishing</div><div style="background-color: inherit;">随便?/div><div style="background-color: inherit;">String wishing = "试";</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">参数10 Q?nbsp;Ip地址   client_ip</div><div style="background-color: inherit;">String client_ip = InetAddress.getLocalHost().getHostAddress().toString();</div><div style="background-color: inherit;">q里可能报异常,需要抓取一?/div><div style="background-color: inherit;"></div><div style="background-color: inherit;">参数11 Q?nbsp;zd名称   act_name</div><div style="background-color: inherit;">随便?/div><div style="background-color: inherit;">String act_name = "试创徏20150906";</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">参数12 Q?nbsp;备注  remark</div><div style="background-color: inherit;">随便?/div><div style="background-color: inherit;">String remark = "试";</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">最后一个参数sign</div><div style="background-color: inherit;">//{֐</div><div style="background-color: inherit;">  Map<String,Object> map = new HashMap<String,Object>();</div><div style="background-color: inherit;">  map.put("nonce_str", nonce_str);</div><div style="background-color: inherit;">  map.put("mch_billno", mch_billno);</div><div style="background-color: inherit;">  map.put("mch_id", mch_id);</div><div style="background-color: inherit;">  map.put("wxappid", wxappid);</div><div style="background-color: inherit;">  map.put("send_name", send_name);</div><div style="background-color: inherit;">  map.put("re_openid", re_openid);</div><div style="background-color: inherit;">  map.put("total_amount", total_amount);</div><div style="background-color: inherit;">  map.put("total_num", total_num);</div><div style="background-color: inherit;">  map.put("wishing", wishing);</div><div style="background-color: inherit;">  map.put("client_ip", client_ip);</div><div style="background-color: inherit;">  map.put("act_name", act_name);</div><div style="background-color: inherit;">  map.put("remark", remark);</div><div style="background-color: inherit;">  String sign = Signature.getSign(map);</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">写一个Signaturec,代码如下Q?/div><div style="background-color: inherit;"></div><div style="background-color: inherit;">import org.xml.sax.SAXException;</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">import com.yxht.core.common.tools.LoadProperties;</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">import javax.xml.parsers.ParserConfigurationException;</div><div style="background-color: inherit;">import java.io.IOException;</div><div style="background-color: inherit;">import java.lang.reflect.Field;</div><div style="background-color: inherit;">import java.util.ArrayList;</div><div style="background-color: inherit;">import java.util.Arrays;</div><div style="background-color: inherit;">import java.util.Map;</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">/**</div><div style="background-color: inherit;"> * User: rizenguo</div><div style="background-color: inherit;"> * Date: 2014/10/29</div><div style="background-color: inherit;"> * Time: 15:23</div><div style="background-color: inherit;"> */</div><div style="background-color: inherit;">public class Signature {</div><div style="background-color: inherit;">    /**</div><div style="background-color: inherit;">     * {֐法</div><div style="background-color: inherit;">     * @param o 要参与签名的数据对象</div><div style="background-color: inherit;">     * @return {֐</div><div style="background-color: inherit;">     * @throws IllegalAccessException</div><div style="background-color: inherit;">     */</div><div style="background-color: inherit;">    public static String getSign(Object o) throws IllegalAccessException {</div><div style="background-color: inherit;">        ArrayList<String> list = new ArrayList<String>();</div><div style="background-color: inherit;">        Class cls = o.getClass();</div><div style="background-color: inherit;">        Field[] fields = cls.getDeclaredFields();</div><div style="background-color: inherit;">        for (Field f : fields) {</div><div style="background-color: inherit;">            f.setAccessible(true);</div><div style="background-color: inherit;">            if (f.get(o) != null && f.get(o) != "") {</div><div style="background-color: inherit;">                list.add(f.getName() + "=" + f.get(o) + "&");</div><div style="background-color: inherit;">            }</div><div style="background-color: inherit;">        }</div><div style="background-color: inherit;">        int size = list.size();</div><div style="background-color: inherit;">        String [] arrayToSort = list.toArray(new String[size]);</div><div style="background-color: inherit;">        Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);</div><div style="background-color: inherit;">        StringBuilder sb = new StringBuilder();</div><div style="background-color: inherit;">        for(int i = 0; i < size; i ++) {</div><div style="background-color: inherit;">            sb.append(arrayToSort[i]);</div><div style="background-color: inherit;">        }</div><div style="background-color: inherit;">        String result = sb.toString();</div><div style="background-color: inherit;">        result += "key=" + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";   //q里是开发者中心里面服务器配置里面的消息加解密密钥</div><div style="background-color: inherit;">        Util.log("Sign Before MD5:" + result);</div><div style="background-color: inherit;">        result = MD5.MD5Encode(result).toUpperCase();</div><div style="background-color: inherit;">        Util.log("Sign Result:" + result);</div><div style="background-color: inherit;">        return result;</div><div style="background-color: inherit;">    }</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">    public static String getSign(Map<String,Object> map){</div><div style="background-color: inherit;">        ArrayList<String> list = new ArrayList<String>();</div><div style="background-color: inherit;">        for(Map.Entry<String,Object> entry:map.entrySet()){</div><div style="background-color: inherit;">            if(entry.getValue()!=""){</div><div style="background-color: inherit;">                list.add(entry.getKey() + "=" + entry.getValue() + "&");</div><div style="background-color: inherit;">            }</div><div style="background-color: inherit;">        }</div><div style="background-color: inherit;">        int size = list.size();</div><div style="background-color: inherit;">        String [] arrayToSort = list.toArray(new String[size]);</div><div style="background-color: inherit;">        Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);</div><div style="background-color: inherit;">        StringBuilder sb = new StringBuilder();</div><div style="background-color: inherit;">        for(int i = 0; i < size; i ++) {</div><div style="background-color: inherit;">            sb.append(arrayToSort[i]);</div><div style="background-color: inherit;">        }</div><div style="background-color: inherit;">        String result = sb.toString();</div><div style="background-color: inherit;">        result += "key=" + LoadProperties.getSystemdefaultValue("APP_KEY");</div><div style="background-color: inherit;">        result = MD5.MD5Encode(result).toUpperCase();</div><div style="background-color: inherit;">        return result;</div><div style="background-color: inherit;">    }</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">    /**</div><div style="background-color: inherit;">     * 从APIq回的XML数据里面重新计算一ơ签?/div><div style="background-color: inherit;">     * @param responseString APIq回的XML数据</div><div style="background-color: inherit;">     * @return 新鲜出炉的签?/div><div style="background-color: inherit;">     * @throws ParserConfigurationException</div><div style="background-color: inherit;">     * @throws IOException</div><div style="background-color: inherit;">     * @throws SAXException</div><div style="background-color: inherit;">     */</div><div style="background-color: inherit;">    public static String getSignFromResponseString(String responseString) throws IOException, SAXException, ParserConfigurationException {</div><div style="background-color: inherit;">        Map<String,Object> map = XMLParser.getMapFromXML(responseString);</div><div style="background-color: inherit;">        //清掉q回数据对象里面的Sign数据Q不能把q个数据也加q去q行{֐Q,然后用签名算法进行签?/div><div style="background-color: inherit;">        map.put("sign","");</div><div style="background-color: inherit;">        //APIq回的数据根据用{֐法q行计算新的{֐Q用来跟APIq回的签名进行比?/div><div style="background-color: inherit;">        return Signature.getSign(map);</div><div style="background-color: inherit;">    }</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">    /**</div><div style="background-color: inherit;">     * 验APIq回的数据里面的{֐是否合法Q避免数据在传输的过E中被第三方改</div><div style="background-color: inherit;">     * @param responseString APIq回的XML数据字符?/div><div style="background-color: inherit;">     * @return API{֐是否合法</div><div style="background-color: inherit;">     * @throws ParserConfigurationException</div><div style="background-color: inherit;">     * @throws IOException</div><div style="background-color: inherit;">     * @throws SAXException</div><div style="background-color: inherit;">     */</div><div style="background-color: inherit;">    public static boolean checkIsSignValidFromResponseString(String responseString) throws ParserConfigurationException, IOException, SAXException {</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">        Map<String,Object> map = XMLParser.getMapFromXML(responseString);</div><div style="background-color: inherit;">        Util.log(map.toString());</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">        String signFromAPIResponse = map.get("sign").toString();</div><div style="background-color: inherit;">        if(signFromAPIResponse=="" || signFromAPIResponse == null){</div><div style="background-color: inherit;">            Util.log("APIq回的数据签名数据不存在Q有可能被第三方改!!!");</div><div style="background-color: inherit;">            return false;</div><div style="background-color: inherit;">        }</div><div style="background-color: inherit;">        Util.log("服务器回包里面的{֐?" + signFromAPIResponse);</div><div style="background-color: inherit;">        //清掉q回数据对象里面的Sign数据Q不能把q个数据也加q去q行{֐Q,然后用签名算法进行签?/div><div style="background-color: inherit;">        map.put("sign","");</div><div style="background-color: inherit;">        //APIq回的数据根据用{֐法q行计算新的{֐Q用来跟APIq回的签名进行比?/div><div style="background-color: inherit;">        String signForAPIResponse = Signature.getSign(map);</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">        if(!signForAPIResponse.equals(signFromAPIResponse)){</div><div style="background-color: inherit;">            //{֐验不q,表示q个APIq回的数据有可能已经被篡改了</div><div style="background-color: inherit;">            Util.log("APIq回的数据签名验证不通过Q有可能被第三方改!!!");</div><div style="background-color: inherit;">            return false;</div><div style="background-color: inherit;">        }</div><div style="background-color: inherit;">        Util.log("恭喜QAPIq回的数据签名验证通过!!!");</div><div style="background-color: inherit;">        return true;</div><div style="background-color: inherit;">    }</div><div style="background-color: inherit;"></div><div style="background-color: inherit;">}</div><div style="background-color: inherit;"></div><div style="background-color: inherit;"></div><div style="background-color: inherit;">先讲到这里,所有参数都准备好了Q下一步是l成xml</div><div style="background-color: inherit;"></div><div style="background-color: inherit;"></div><div style="background-color: inherit;">声明Q工L代码参考微信支付开发的demoQ有些自己做了小改动?/div></div><img src ="http://www.aygfsteel.com/resteater/aggbug/427248.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/resteater/" target="_blank">休息食客</a> 2015-09-10 15:35 <a href="http://www.aygfsteel.com/resteater/archive/2015/09/10/427248.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java解析xml文gQdom4j方式Q?/title><link>http://www.aygfsteel.com/resteater/archive/2015/02/11/422872.html</link><dc:creator>休息食客</dc:creator><author>休息食客</author><pubDate>Wed, 11 Feb 2015 09:23:00 GMT</pubDate><guid>http://www.aygfsteel.com/resteater/archive/2015/02/11/422872.html</guid><wfw:comment>http://www.aygfsteel.com/resteater/comments/422872.html</wfw:comment><comments>http://www.aygfsteel.com/resteater/archive/2015/02/11/422872.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/resteater/comments/commentRss/422872.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/resteater/services/trackbacks/422872.html</trackback:ping><description><![CDATA[     摘要: java解析xml文g的方式有几种Q下面介l用dom4j方式解析1、先看一Dxml内容 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->  1 <configs>  2 &nb...  <a href='http://www.aygfsteel.com/resteater/archive/2015/02/11/422872.html'>阅读全文</a><img src ="http://www.aygfsteel.com/resteater/aggbug/422872.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/resteater/" target="_blank">休息食客</a> 2015-02-11 17:23 <a href="http://www.aygfsteel.com/resteater/archive/2015/02/11/422872.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java获取根目录,d配置文ghttp://www.aygfsteel.com/resteater/archive/2015/01/30/422583.html休息食客休息食客Fri, 30 Jan 2015 07:01:00 GMThttp://www.aygfsteel.com/resteater/archive/2015/01/30/422583.htmlhttp://www.aygfsteel.com/resteater/comments/422583.htmlhttp://www.aygfsteel.com/resteater/archive/2015/01/30/422583.html#Feedback1http://www.aygfsteel.com/resteater/comments/commentRss/422583.htmlhttp://www.aygfsteel.com/resteater/services/trackbacks/422583.htmlJava获取根目录\径有很多U方法,但是Ҏ应用E序所部v的环境和中间件不同,获取的\径可能也不同。下面我提供一U方法,解决q个问题?br />
         String path = InterfaceConfig.class.getResource("").getPath().toString();//获取cL在\?br />         if (path.contains(".jar")) {
             path = path.replace("/", File.separator);//?换成\Q如果是linux环境Q还?
             path = path.replace("file:", "");//Lfile
             path = path.replace("classes\\", "");//Lclasses\
             if (path.startsWith("\\")) {
                 path = path.substring(1);//LW一个\,如:、\D:\TongWeb...  ,在linux上没有这U情?br />             }
             path = path.split("WEB-INF")[0]+"WEB-INF"+File.separator+"classes";
        } else {
             path = InterfaceConfig.class.getResource("/").getPath().toString();//获取根\?br />        }
        File file = new File(path + File.separator + "InterfaceConfig.xml");

q段代码什么意思呢Q?br />1、第一行是获取InterfaceConfig.classq个cL在的路径Q这个InterfaceConfig.class可以换成你这D代码所在的cR?br />2、判断\径中是否包含.jarQ就是说q段代码所在的cLl构建的时候是不是打入jar包里Q如果在jar包里Q就L一些内容,如file: ,classes\\,
    然后ҎWEB-INF切割Qƈ拼出根目录?br />3、如果没有打入jar包,那更单了Q直接通过获取根\径方法就解决了?br />4、最后读取classes路径下的InterfaceConfig.xml配置文g?br />


休息食客 2015-01-30 15:01 发表评论
]]>
JAVA解析内容格式为XML的字W串http://www.aygfsteel.com/resteater/archive/2014/09/28/418355.html休息食客休息食客Sun, 28 Sep 2014 07:01:00 GMThttp://www.aygfsteel.com/resteater/archive/2014/09/28/418355.htmlhttp://www.aygfsteel.com/resteater/comments/418355.htmlhttp://www.aygfsteel.com/resteater/archive/2014/09/28/418355.html#Feedback0http://www.aygfsteel.com/resteater/comments/commentRss/418355.htmlhttp://www.aygfsteel.com/resteater/services/trackbacks/418355.html假如有一个字W串的内Ҏxml格式Q如Q?/p>

 

        String aa = "<row>"+
                      
"<user>"+
                        
"<userid>1000</userid>"+
                        
"<username>aaa</username>"+
                        
"</user>"+
                      
"<user>"+
                        
"<userid>1001</userid>"+
                        
"<username>bbb</username>"+
                      
"</user>"+
                    
"</row>";

q是一个字W串Q不是一个XML文档Q只是该字符串里面的内容是XML格式Q该怎么解析呢?
假如我有一个User对象Q有userid和username属性,然后把该字符串里面的数据解析到User对象来?br />思\Q把该字W串先解析ؓdocment树Ş文档Q然后获取根元素rowQ再然后获取根元素的W一个子元素user,然后获取user元素的第一个子元素useridq把该值存入user对象?br />看代码:

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

public class test {    

    
/**
     * 
@param args
     
*/

    
public static void main(String[] args) {
        
// TODO Auto-generated method stub

        String aa 
= "<row>"+
                      
"<user>"+
                        
"<userid>1000</userid>"+
                        
"<username>aaa</username>"+
                        
"</user>"+
                      
"<user>"+
                        
"<userid>1001</userid>"+
                        
"<username>bbb</username>"+
                      
"</user>"+
                    
"</row>";
        test t 
= new test();
        List
<User> lu = new ArrayList<User>();
        User user 
= new User();
        lu 
= t.Analysis(aa, lu, user);
        
for(User u : lu){;
            System.out.println(u.getUserid()
+"  "+u.getUsername());
        }

    }

    
    
public test(){
        
    }

    
    
public List<User> Analysis(String s,List<User> lu,User user){
        Document doc 
= null;             
        
try {
            doc 
= DocumentHelper.parseText(s);// 字W串转ؓdocument树Ş格式
        }
 catch (DocumentException e) {
            e.printStackTrace();
        }
         
        Element rootElt 
= doc.getRootElement(); // 获取根节?/span>
        Iterator iter = rootElt.elementIterator("user"); // 获取根节点下的子节点user
        while (iter.hasNext()) {
            user 
= new User();
            Element recordEle 
= (Element) iter.next();
            Iterator iters 
= recordEle.elementIterator("userid"); // 获取子节点user下的子节点userId
            while(iters.hasNext()){
                Element userId 
= (Element) iters.next();
                user.setUserid(Long.parseLong(userId.getText()));
            }

            iters 
= recordEle.elementIterator("username"); // 获取子节点user下的子节点username
            while(iters.hasNext()){
                Element username 
= (Element) iters.next();
                user.setUsername(username.getText());
            }

            lu.add(user);
        }
 
        
return lu;
    }


}


class User {
    
private Long userid;
    
private String username;
    
public Long getUserid() {
        
return userid;
    }

    
public void setUserid(Long userid) {
        
this.userid = userid;
    }

    
public String getUsername() {
        
return username;
    }

    
public void setUsername(String username) {
        
this.username = username;
    }
    
}

整个解析q程及思\在AnalysisҎ里面Q注释写清楚了,可以自己ȝ!



休息食客 2014-09-28 15:01 发表评论
]]>
Maven+jetty启动配置http://www.aygfsteel.com/resteater/archive/2014/09/20/418116.html休息食客休息食客Sat, 20 Sep 2014 06:04:00 GMThttp://www.aygfsteel.com/resteater/archive/2014/09/20/418116.htmlhttp://www.aygfsteel.com/resteater/comments/418116.htmlhttp://www.aygfsteel.com/resteater/archive/2014/09/20/418116.html#Feedback0http://www.aygfsteel.com/resteater/comments/commentRss/418116.htmlhttp://www.aygfsteel.com/resteater/services/trackbacks/418116.html当我们的j2ee目建好后,如果用jetty启动Q要怎么配置呢?
直接打开目的pom.xml文gQ添加如下配|:
<plugins>
<plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>6.1.26</version>
</plugin>
</plugins>
注意Q这D配|在你复制到pom.xml文g里的时候,应该攑֜<build></build>里面Q如
<build>
    <finalName>WechatTest_Core</finalName>
    <plugins>
<plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>6.1.26</version>
</plugin>
  </plugins>
    ....
    ....
  </build>
说明Q该配置的groupId和artifactId不用改变Q就是这P而version具体用哪个版本,可以在中央仓库里找,q里我用的是6.1.26版本Q配|好了后保存?br />接下来是启动目Q第一ơ要配置一下启动信息,run as->Run Configurations...
如图Q?br />ok了,输入http://localhost:8081/可以访问了

休息食客 2014-09-20 14:04 发表评论
]]>
maven+hibernate3构徏目的pom.xmlhttp://www.aygfsteel.com/resteater/archive/2014/09/07/417740.html休息食客休息食客Sat, 06 Sep 2014 17:08:00 GMThttp://www.aygfsteel.com/resteater/archive/2014/09/07/417740.htmlhttp://www.aygfsteel.com/resteater/comments/417740.htmlhttp://www.aygfsteel.com/resteater/archive/2014/09/07/417740.html#Feedback0http://www.aygfsteel.com/resteater/comments/commentRss/417740.htmlhttp://www.aygfsteel.com/resteater/services/trackbacks/417740.html<project xmlns="http://maven.apache.org/POM/4.0.0   <modelVersion>4.0.0</modelVersion>
<!--目基本信息-->

  <groupId>com.loubing.test</groupId>
  <artifactId>myhibernate</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>myhibernate</name>
<!--依赖包来源,q里是我自己建立的一个私服。也可以?a >https://repo1.maven.org/maven2/
  -->
  <url>http://localhost:10000/nexus/content/groups/public</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <!-- hibernate -->
    <dependency>
 <groupId>c3p0</groupId>
 <artifactId>c3p0</artifactId>
 <version>0.9.1.2</version>
  </dependency>
            
   <!-- dHibernate依赖 -->   
    <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate3</artifactId> 
      <version>3.0.2</version> 
    </dependency> 
    <!--以下的包其实可以用hibernate-coreQ但是我觉得太多了,Ҏ需要,把几个重要的单独添加进?->
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.1.Final</version>
    </dependency>
    <dependency>
     <groupId>commons-collections</groupId>
     <artifactId>commons-collections</artifactId>
     <version>3.1</version>
 </dependency>
 <dependency>
     <groupId>javax.transaction</groupId>
     <artifactId>jta</artifactId>
     <version>1.1</version>
 </dependency>
    <dependency>   
        <groupId>dom4j</groupId>   
        <artifactId>dom4j</artifactId>   
        <version>1.1</version>
    </dependency>
    <dependency>   
        <groupId>org.slf4j</groupId>   
        <artifactId>slf4j-api</artifactId>   
        <version>1.4.2</version>
    </dependency>
    <dependency>   
        <groupId>org.slf4j</groupId>   
        <artifactId>slf4j-log4j12</artifactId>   
        <version>1.4.2</version>
    </dependency>
    <dependency>   
        <groupId>javassist</groupId>   
        <artifactId>javassist</artifactId>   
        <version>3.11.0.GA</version>
    </dependency>
    <!-- doracle10g jdbc driver --> 
    <dependency>   
        <groupId>com.oracle</groupId>   
        <artifactId>ojdbc14</artifactId>   
        <version>10.2.0.1.0</version>
    </dependency>
  </dependencies>
</project>



休息食客 2014-09-07 01:08 发表评论
]]>
վ֩ģ壺 | ï| | ɣ| | | п| Ԫ| | | Ͱ| | | Ӧ| ӡ| | | | | | ʯ| ³ƶ| | | | β| | ʡ| | | | ɽ| Ժ| | | Ӵ| | ƽ| | ֦| ̰|