TA的每日心情 | 衰 2021-2-2 11:21 |
---|
签到天数: 36 天 [LV.5]常住居民I
|
java实现微信公众平台开发项目源码# w+ _' E; H/ d# F( f) ]
本文向大家介绍使用Java来实现微信公共平台功能,实现根据回复的内容返回对应的消息。供大家学习使用。
* W1 s: t. z5 B3 q微信服务端收发消息接口:WechatServlet.java' Y, w8 r0 J3 l2 _; [" C8 A
- package demo.servlet;0 x. Z+ R. C0 k
- : _* Y4 U2 ?$ o( u( ?/ d
- import java.io.BufferedReader;
/ V) z, ?1 _% x$ d - import java.io.IOException;
. D& m; w: F0 T# E - import java.io.InputStream;
' [- q5 X- P4 T: o, m+ y$ n - import java.io.InputStreamReader;
" r2 I" B' @* h4 S5 H - import java.util.Arrays;; D0 I+ c6 }6 v4 O; X$ I/ |
@: d3 Q/ T5 n% y ?( C- import javax.servlet.ServletException;- @# ^/ @8 K$ [: B0 \7 _- a
- import javax.servlet.http.HttpServlet;
& H( [ L$ d g) V - import javax.servlet.http.HttpServletRequest;
; C! {6 u* B& n" S% a2 t0 Q1 D& } - import javax.servlet.http.HttpServletResponse;
: n& E' f8 C# R9 z; z2 T2 [ - 1 p% U0 h2 ~, [" f. R4 R) q
- import demo.process.WechatProcess;
5 Q/ X8 W N7 f7 H" O- O - import demo.util.SHA1;
7 k% F) z( ~8 [& E5 s - /**
+ A" r U* }! ?! f0 f. M. v9 G - * 微信服务端收发消息接口
: M& w1 K" V* H4 H - *
. \6 Q) p, `4 H! P: x# N - * @author 科帮网
/ W' t( N6 a/ m# h0 j1 J - *
) k$ f2 o# T# ~. L! d - */
$ J& j( s& O" X: y0 \. R* L! L - @SuppressWarnings("serial")
% Q& e8 b' Y6 {& u. ? Z, F - public class WechatServlet extends HttpServlet {: v+ {$ K. g- k+ _; j* ]; q
- * D: S4 b5 S/ h8 T& C
- // 自定义 token
% P$ y0 X3 t3 ?! J$ v7 u - private String TOKEN = "52itstyle"; 0 v- r: z0 n, ]' ]& e
- public void doGet(HttpServletRequest request, HttpServletResponse response)* d+ h- w' D+ c8 D
- throws ServletException, IOException {
' ~, s7 @8 ?% F1 S# L4 R - String signature = request.getParameter("signature"); // 随机字符串" g$ \- N% o& M( [: h% D) F6 Q- b
- String echostr = request.getParameter("echostr"); // 时间戳
* @# K$ W- }! x! B) b% a1 [ - String timestamp = request.getParameter("timestamp"); // 随机数
% ^. z; Y1 w! F6 Q8 ? - String nonce = request.getParameter("nonce");3 P) ^6 T5 [! C$ U
- $ _) t) s0 h" M/ z" b7 ?# z4 U( P& Q
- String[] str = { TOKEN, timestamp, nonce };
- \" O6 q! u* {' o6 C* O - Arrays.sort(str); // 字典序排序
! ^% D" o( M; z3 M: {4 |" D ] - String bigStr = str[0] + str[1] + str[2]; // SHA1加密
$ y0 R6 I4 W3 t6 p. r3 }, Y - String digest = new SHA1().getDigestOfString(bigStr.getBytes()).toLowerCase();
; y6 R# O, x8 u - // 确认请求来至微信
6 [- k5 e+ o3 L- f% p; f# G - if (digest.equals(signature)) {0 u# p I; ] {# ? h) [
- request.setCharacterEncoding("UTF-8");
3 S, ~$ n$ f7 Q# P: ~3 ~( S - response.setCharacterEncoding("UTF-8");
' c, W! Q3 y- } - 0 C1 j) b8 ^5 O6 U A# K
- /** 读取接收到的xml消息 */
* A( H$ j7 G6 Q7 c$ q0 }7 ^# v- G! B9 q - StringBuffer sb = new StringBuffer();
3 Q$ d7 O, z) Q4 o2 o0 Z - InputStream is = request.getInputStream();" T2 \$ M3 C+ T2 Y! D
- InputStreamReader isr = new InputStreamReader(is, "UTF-8");3 {& ?6 a1 X. Z# s8 S
- BufferedReader br = new BufferedReader(isr);
3 ]3 l/ w3 R( p" Z8 @! `3 t0 K - String s = "";3 |1 }+ ^9 ^9 H5 {* a, K
- while ((s = br.readLine()) != null) {
# ~' _; a" x% R A( G* W - sb.append(s);9 e( z- R4 G0 t5 `# J+ G
- }
8 s/ V% ~, [' i6 s: C2 e: h - String xml = sb.toString(); //次即为接收到微信端发送过来的xml数据3 M* D! Y3 I1 d1 C0 z5 f
-
R9 @0 S7 f1 n# ` - String result = "";+ { l! S8 k$ H
- /** 判断是否是微信接入激活验证,只有首次接入验证时才会收到echostr参数,此时需要把它直接返回 */
0 a+ \+ B9 X$ u' s - if (echostr != null && echostr.length() > 1) {; \: B7 r" J& s
- result = echostr;: p4 Z# A$ C% l
- } else {* x& z7 b$ }9 v6 p9 h
- //正常的微信处理流程
$ w. N0 L) y6 l - result = new WechatProcess().processWechatMag(xml);/ D* R& T) S) j# ^* f( q( g
- }
; c; \, v+ I3 x7 s6 X4 S+ { - System.out.println("说的什么"+result);
% c; O$ Q0 R* R \, j0 E" d3 p - response.getWriter().print(result);+ @& ^5 ~3 @3 J' j! S" n
- }
8 W( H' b. I! H! N3 g; l - }; I8 d: g1 t/ `
5 `7 `+ K/ p4 n! b$ }4 C6 L- /**
% s0 K( V t5 C) }% D - * The doPost method of the servlet. <br>. |( G$ ^/ z0 F0 `" ^
- * ' s+ }4 h' V2 |) l& [3 Q) y
- * This method is called when a form has its tag value method equals to
% C: _4 Y# L: z - * post.
# z6 L% I5 V* g - *
8 H; U* f, v- e, i8 l% B! S - * @param request
8 e) P* Q' \0 p% T - * the request send by the client to the server
}3 d/ Y, O' F5 p - * @param response
- _- r$ p/ u: t - * the response send by the server to the client& t1 H8 J! I% `; t
- * @throws ServletException* v9 X. v6 P! y G: H$ k7 e4 y- I
- * if an error occurred
; c/ c. {' a0 V7 X# i1 N - * @throws IOException- U; |9 v5 d. B" s* b& h
- * if an error occurred$ I7 r- q- Y% q2 N
- */# G6 ?' Z& m* `' f3 q" N+ W4 T! t- L9 M& _
- public void doPost(HttpServletRequest request, HttpServletResponse response)+ }" C1 h9 d0 D j# v% K
- throws ServletException, IOException { ?- r- X* C. F) }( A8 g* J6 `
- doGet(request, response);
5 }" u m) {% f& o+ | - }
; U4 i& K3 ?9 m r - # ?# L! ^7 Q8 b% U; g2 z! M
- }5 _3 Z* C6 Y M$ u) P& U
复制代码 接收到的微信xml实体类:ReceiveXmlEntity.java0 n+ C- @$ r" ^! y$ L% v
- package demo.entity;) g! [0 t1 b+ Z
- /**
8 Y/ J/ k& i5 |3 f - * 接收到的微信xml实体类2 L5 Q( T9 D* W6 Z; Z$ C
- * @author 科帮网
* H% u/ n% a4 Q( I - *
$ G6 t( B+ C7 A6 O+ e" F - */
& q4 F5 a O% |9 o& D# n/ p - public class ReceiveXmlEntity {3 V3 f' w- ], s9 L
- private String ToUserName="";
/ }5 k% t; [9 b+ d+ W. G, u7 m$ P - private String FromUserName="";% i' R" t1 |" Y3 c
- private String CreateTime="";+ S) W- r$ i/ ]; ]" K" H5 z
- private String MsgType="";
8 N$ V& k }8 ] - private String MsgId="";
6 i, _$ ]0 N) m' a- l3 l - private String Event="";: ]* D$ }6 D6 f
- private String EventKey="";
4 \7 x; H% ^ t5 D8 ^ - private String Ticket="";1 f8 k' a, |* x& g8 h9 l
- private String Latitude="";
1 ?; Z$ L- O2 N3 v' C+ q - private String Longitude="";
- {) w$ i8 D3 h - private String Precision="";# o7 R5 m( S/ i- d7 I
- private String PicUrl="";
5 q# g4 ?9 G. c) K# ?# A6 c - private String MediaId="";
) E# M/ E: s, q6 |$ Z - private String Title="";
1 ]5 e! {8 O. F( N6 f* X1 B* C - private String Description="";
e+ Z' B9 I Q# i4 ~7 ?' X* ^ - private String Url="";2 k1 }3 T1 I: t' i2 j
- private String Location_X="";: L5 C @9 u" C& @" y- V/ [2 y6 q
- private String Location_Y="";& [& h" }1 }+ Z: U
- private String Scale="";) m* b- E2 B4 e0 K: k# ?1 l
- private String Label="";+ B3 {$ {) ]" B4 N' [+ R- P, k2 @
- private String Content="";
5 ^$ s2 ]- q, w) } - private String Format="";' L# R, h, o! w B* K% E) C' D
- private String Recognition="";
/ z% `8 h: v, l7 x5 K8 Q -
/ ^, V: r: W/ t4 a - public String getRecognition() {' H5 b+ D$ I$ P6 b9 ~ L
- return Recognition;$ I1 r9 i& \9 b) o t: p# K
- }& @( I/ }: |4 P G0 r- I
- public void setRecognition(String recognition) {9 h" e& [, [' k; U8 o0 l
- Recognition = recognition;1 N+ K1 w2 N+ z2 `# [! R
- }
) S& s( d+ x$ {% G2 A - public String getFormat() {, S1 g4 r6 z% _7 Y: r
- return Format;
, i$ C- g) H4 K' C8 [, O - }
( b& A! r" ^, I0 O1 F; q - public void setFormat(String format) {
5 m. x3 M/ Z; T& r; B - Format = format;
5 u0 d9 d: R0 Y7 a - }
q# `" F/ _4 S6 S7 S - public String getContent() {
+ ` W" c' t7 M" ^0 d - return Content;
$ [" S+ n/ n* @: }2 M8 U4 ] - }
. E: J! _' x; L0 t4 H - public void setContent(String content) {
! T' |! B, C7 S! X - Content = content;
1 M, f$ u" H- u* n; E - }; N, M: R+ g: j) B3 C
- public String getLocation_X() {
! K* d8 A4 e1 a0 a0 o5 B! d - return Location_X;
5 i& t, n: y6 N - }8 ]; p# I2 P* R1 T4 l# z$ ]
- public void setLocation_X(String locationX) {' \" S+ {# U/ v9 D# k
- Location_X = locationX;
$ D& ^/ D2 [$ o1 a0 O9 k - }
- M2 A& I$ i7 z, E3 S. j6 T0 y - public String getLocation_Y() {
8 q6 @& }. @3 G0 u* X - return Location_Y;1 }( I" x& M6 T7 _2 {) q
- }
2 y: x) Q' V, k! l* u/ T! z: }3 x - public void setLocation_Y(String locationY) {
1 j+ J' ^- g! k7 {" ~ E7 P - Location_Y = locationY;- r0 Z! @! [2 `+ E( `
- }
# R2 u2 h. G1 ` x - public String getScale() {( G, L/ h5 i% {5 O5 L" m* j. P5 t
- return Scale;3 {% b, S, z. J
- }
# s- T4 {4 ]: M. T - public void setScale(String scale) {+ ?, B6 [# J' f/ L% m8 L
- Scale = scale;$ m1 ?. v" n! w- w2 n) ^* i& k
- }
* `1 a' F( v- Y% h) A$ q - public String getLabel() {
: D) X C" x# S O - return Label;0 h* [2 a. O* ?) o
- }* X$ Y) a6 S/ F0 N; q. m
- public void setLabel(String label) {
; i1 n, g/ w( U+ ~8 s1 N8 y - Label = label;
& u8 H! T/ j. x9 q' ~( V - }
+ C+ b/ V4 D# A/ ?. k* e - public String getTitle() {# s: n) t7 m) U( q' Y" I
- return Title;: w" S1 j' _7 c) j
- }
" _( q# f' \5 t* c4 V& I - public void setTitle(String title) {+ q! _# H9 C5 `- n0 m6 v* Q0 g6 l0 [
- Title = title;+ ^$ ^2 D) c+ |. t
- }* K& ~/ E: X, N& F) c
- public String getDescription() {
4 [$ Q8 `. ~/ ]. r6 t$ M - return Description;
5 K% K( W' b; n8 I U3 A - }
- w. e @; F9 ]$ r1 j- Y - public void setDescription(String description) {. v8 E, E' _$ J. ?3 I- c
- Description = description; v: Q5 @: c4 B8 E
- }/ Q2 b, ~% S7 v3 b4 q
- public String getUrl() {
) `4 k' H' f) E' v8 Y/ x7 ] - return Url;" L* i. `# K5 S, x" [( Z
- }
& d. U0 w u( s - public void setUrl(String url) {
* J( X* q8 H" E& v5 | - Url = url;; @+ S8 z, x9 M3 g! H" j
- }3 Y1 |+ Y3 R1 f% f
- public String getPicUrl() {
$ B' \7 E) M6 |1 e - return PicUrl;$ e: R6 s& d: Z1 O
- }
# }( n" d4 C* N1 V# }- B' M - public void setPicUrl(String picUrl) {
- W' B5 r( p# V4 |! M, [# M3 H - PicUrl = picUrl;
! a7 C) U$ ]7 t1 {0 q6 |2 x - }
" R( B' F) ^/ \: e+ x4 d1 q- Y - public String getMediaId() {
1 s7 z4 N7 a% }* F& l1 l3 T' w - return MediaId;" R7 n* b2 X( Y7 Z j- d
- }
% D* o% s6 B7 H0 i0 u5 l - public void setMediaId(String mediaId) {
1 _) w) ]: R- v) {* ]2 ^6 L8 R - MediaId = mediaId;: W; v6 V# D6 I/ f6 d* s8 B
- }
, s B, {9 [0 n - public String getEventKey() {1 L# Z. }7 Z2 h8 E( d' {
- return EventKey;! R* m1 Y) {( Y( c# Z9 `4 b9 t
- }
! w8 d$ W6 V' M h- |; H* D - public void setEventKey(String eventKey) {+ X5 G2 ^, n# y1 m2 i, V* Z
- EventKey = eventKey;
$ `& w! D) l, f" m9 Z - }0 u2 e% x! W. u# S6 K5 O
- public String getTicket() {% M! u+ {3 a& r& l! d
- return Ticket;% c# X! p; {2 V+ g: `' K$ t
- }
9 |/ U, m% t- P- @- V - public void setTicket(String ticket) {. f m% |) R+ {- f
- Ticket = ticket;+ O4 k: P4 }) k) P" V) Z
- }- S# s8 Q8 o+ K" h1 W H! ]
- public String getLatitude() {4 v+ Z( d" N2 z! N4 F5 G- _; E
- return Latitude;. x, Y/ T/ ?$ r- f" m
- }& ?5 v3 n% y4 R: m. ^# v
- public void setLatitude(String latitude) {4 ?2 ~- X1 {4 D0 S. ~' A
- Latitude = latitude; u9 `: N2 b" W" S/ k1 y
- }
2 E5 x4 Y+ x9 q* H H, H* W - public String getLongitude() {: ^3 q" L7 v3 Z* `7 e/ S* J
- return Longitude;) f2 Z$ U2 W& ?$ P1 O% L1 ?2 j
- }! t9 a/ @6 z7 Y' E9 X5 f
- public void setLongitude(String longitude) {
+ S/ `; f1 V$ j% e6 r - Longitude = longitude;$ C- w2 E6 v$ N' d* r5 b$ y
- }
* y1 n. A* \" N7 g, a, O+ D8 c' r - public String getPrecision() {- l+ f1 P# O x+ S
- return Precision;
% x! w5 M! ~ f5 m: H - }
d6 u+ R: `; e; H* V6 ` - public void setPrecision(String precision) {
8 P: `" o9 }! R: U W - Precision = precision;+ a- x: J' s; U& j# G# l, _( p
- }0 \5 ~# _" g: i
- public String getEvent() { C6 @' g5 @; X
- return Event;9 l0 t! v" }; \' J _ N
- }
0 ~' f. a# |9 n: S - public void setEvent(String event) {
" W0 i+ O2 h+ g j. Q* V% D - Event = event;
, V: _1 s* r* D' O- ? - }
$ |' g' q! Q. I" d - public String getMsgId() {
# t9 J. q( z# I: Q; R$ n0 Y - return MsgId;
! O) s) T: Y8 `: u) x m$ y) S - }( K' M$ x$ P5 }) p
- public void setMsgId(String msgId) {
! V$ R! s j. x$ S# ~: J- j - MsgId = msgId;
e' B/ W% U. G2 ~$ M% Q8 q& } - }/ W6 o! S8 z% K0 ?' d2 B$ i: }
- public String getToUserName() {
$ M# Q! Z0 R9 u h. \+ g/ i - return ToUserName;9 J7 l/ R2 Z8 F
- }
H6 @2 ]( f7 {5 p* v - public void setToUserName(String toUserName) {
( M, }( M+ s& w$ T: R8 N - ToUserName = toUserName;
! i& L# y. d! P- z P# K - }. l3 p% j* f6 ^+ k
- public String getFromUserName() {" g: ]! d' ]) K) E8 j
- return FromUserName;- E7 `" b) t l+ w# a' ~
- }
+ \- V7 O3 W7 Y) a0 L3 J( }0 O - public void setFromUserName(String fromUserName) {8 [5 R" |( t& |/ o4 I0 M
- FromUserName = fromUserName;, ?: q. X% U. K9 s( t
- }$ c, R! ?1 v) [! I- f
- public String getCreateTime() { b8 ` b5 B7 E
- return CreateTime; |7 l7 w b& }2 l0 H( f6 \; J5 U' K
- }. x( W" ~( k; h) t
- public void setCreateTime(String createTime) {5 B) c) ~$ R8 @' j! C% T
- CreateTime = createTime;
9 e. k# ?5 D4 A$ U. a - }4 O$ ]8 p. F, U! X9 D
- public String getMsgType() {) O& r, d8 O" R Z; \
- return MsgType;
) L Q Z S& z1 c }* x+ T) @ - }# j4 F/ |' ?: ]! R, d
- public void setMsgType(String msgType) {% J& v3 {3 w; o8 J
- MsgType = msgType;
( e" k, s* ?) w: c7 @$ }0 M - }
; o* k# D, p; {% K - }
$ X2 o# V" S; W- V2 g6 K
复制代码 调用图灵机器人api接口,获取智能回复内容 TulingApiProcess.java) s3 x# Q. `2 ?) j# G8 v) h: h
, a0 h/ l) |) V: \- package demo.process;6 O. m2 s; Q3 f6 T$ ?5 h# D% k
- - u- {( q- I7 k% {
- import java.io.IOException;
$ f2 Y$ {+ b$ p2 H2 s) ~- t - import java.io.UnsupportedEncodingException;
/ i1 h( J( u2 e1 M" o/ X8 n - import java.net.URLEncoder;- J* m- A4 k3 X3 v; ]0 N7 o
$ w7 \# g0 M. m7 F$ \- import org.apache.http.HttpResponse;
) W9 V3 ?: T$ r& Q8 b3 s: X - import org.apache.http.client.ClientProtocolException;
: i- u) C/ g9 [+ C% Z - import org.apache.http.client.methods.HttpGet;
' ?* a- E8 M1 B - import org.apache.http.impl.client.HttpClients;
7 `( W7 I8 D/ k- { - import org.apache.http.util.EntityUtils;* c5 G) s. C% W3 w+ v& [
- import org.json.JSONException;
. S6 `$ U/ P* I - import org.json.JSONObject;
4 H: I: g E( ` - ; A4 R( H( o f0 m) S
- /**
3 y8 P4 ?2 J! W2 J" F# k; t/ _ - * 调用图灵机器人api接口,获取智能回复内容
; y3 |% l* @7 a8 L8 k3 x) _ i - * @author 科帮网) ~9 w# C, {+ [9 z
- *
+ ~, ~9 j S# I% A: j# h3 v - */
3 C1 a2 Z4 t( p2 F - public class TulingApiProcess {
& R- R: D$ C& f! V" d( _ - /**3 F8 a: L5 `: ^6 V; R
- * 调用图灵机器人api接口,获取智能回复内容,解析获取自己所需结果9 g8 u2 |, a/ h# T# O
- * @param content
8 W" D+ g" S1 S7 R0 C - * @return, d6 F6 [6 W9 u" L. i G" }; f
- */, F0 ]9 l4 @/ ^5 E) ^" E) J# N& m
- public String getTulingResult(String content){* D$ ~+ K! i$ @% A, e2 _: H
- /** 此处为图灵api接口,参数key需要自己去注册申请 */
/ l. t9 X3 R0 o8 s- F( e/ v - String apiUrl = "http://www.tuling123.com/openapi/api?key=2a31b2f601f74b54ea13db1c82fe5d71&info=";
0 P! d5 g- b$ o! `3 N4 X - String param = "";. k9 s: c; J1 g6 ~6 C
- try {- f( d2 j+ P% h
- param = apiUrl+URLEncoder.encode(content,"utf-8");/ x' O; H0 x; T; l& x4 u
- } catch (UnsupportedEncodingException e1) {* D9 R, G; @/ y
- e1.printStackTrace();3 b& X7 x! Y" a0 @# n+ g
- } //将参数转为url编码( a+ ?% \$ _( o, H4 g' x
- /** 发送httpget请求 */
9 T/ D' B, M" z* L1 u2 l& G0 n, @( }3 S - HttpGet request = new HttpGet(param);
4 n8 D1 F! e: O! d& c - String result = "";0 _& H. q- q- i' d- q \+ p
- try {
% G8 W; b2 F& s8 K - HttpResponse response = HttpClients.createDefault().execute(request);
( d4 F8 {8 |4 Y' }( d3 q! l - if(response.getStatusLine().getStatusCode()==200){
$ T1 o0 H/ H+ d) X - result = EntityUtils.toString(response.getEntity());
$ @+ p7 R8 n& U1 b - }' Z& \) m2 r1 _) b+ O3 ^. |
- } catch (ClientProtocolException e) {
0 y. E A+ n. C3 _( z* c# O - e.printStackTrace();3 Q+ e: R, _, O" o
- } catch (IOException e) {) y2 p4 T' D- q, O- Z; B
- e.printStackTrace();
( h8 \- I9 z3 ~4 | - }
0 J# q0 c |1 m% h' w5 R, j - /** 请求失败处理 */9 [9 }# t2 \3 ^" L0 b: f
- if(null==result){
7 U, G$ y2 ~( E8 t% _! L - return "对不起,你说的话真是太高深了……";
' }7 ^- r4 ~: S4 q6 g; l5 v - }7 }, ]+ g" K& u: k
- . c( g' V H# F) P' o: C* Z
- try {
+ D' f% D& g5 H& X u7 x7 M, i - JSONObject json = new JSONObject(result);
0 ^" Q0 k0 Z+ t" q- r' a! E - //以code=100000为例,参考图灵机器人api文档
+ L$ v- y! [8 F# n. |% h4 n! \& C - if(100000==json.getInt("code")){, B7 F# ?5 w0 d! Z+ f
- result = json.getString("text");
- a) E' e" a7 Y% M: B) V' o - }
3 P- t! W/ c* j3 i( p' V - } catch (JSONException e) {
+ F( k- o$ j/ P2 J7 e - e.printStackTrace(); v4 {3 f8 x# O0 @" w4 V0 P$ Y: M0 m
- }8 i5 v3 ]' d, t; s$ H5 i
- return result;; g7 X0 S/ u, t9 M
- }6 k5 l. c, M0 j/ w2 U8 _
- }
, Z' q! X k, D6 M5 {* J$ E
复制代码 $ M% y" H2 S/ Q& H+ A$ U
web.xml 配置:
9 i/ c7 \7 J6 t: P) K0 P7 h9 m- <?xml version="1.0" encoding="UTF-8"?>0 N+ j- s' O+ X% k' I! O0 i4 e
- <web-app version="2.5"
8 h! p+ c# j' o! u R* Z - xmlns="http://java.sun.com/xml/ns/javaee"
6 N C$ u# H" r9 F* ~ _ - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" % K- z& i& z) \0 w, E+ ~9 V- j
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 2 n5 E8 X+ K8 m6 G5 Z6 ?
- http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> f, [* C* M0 Q; S3 `
- <servlet>0 b. a/ w6 D9 x1 `6 f9 N& y" ]- C
- <servlet-name>WechatServlet</servlet-name>
4 ~, Y4 R/ m9 @! M - <servlet-class>demo.servlet.WechatServlet</servlet-class>, M* H6 p Q8 M h
- </servlet>
p9 z4 d9 I' l
+ y7 S3 @+ y% v) D# R1 [! w q- <servlet-mapping>
/ b# R! @* b9 c! x) d - <servlet-name>WechatServlet</servlet-name>
7 g! p0 u' t# E& G7 b - <url-pattern>/wechat.do</url-pattern>
9 K8 [" ^/ U F% H" B9 Q; h/ W: @ - </servlet-mapping>
. F# R) ?( D/ \. @ - <welcome-file-list>
( |* O; o% a4 q2 a Z0 f - <welcome-file>index.jsp</welcome-file>
( u! w3 }; M9 z! W$ Z) _- E - </welcome-file-list>
8 e) }: M" x; K- O: f6 Y* } - </web-app>/ L3 u" S9 ^& X5 L, s% V& X
复制代码 2 Y B1 C5 [& ?7 P9 Y. j6 m! j
项目源码下载地址:; w1 Z. B3 V" J4 ~. a
/ t, r* W0 D6 R' ~8 }! F$ h8 Q$ C7 V. ?: n7 M
|
|