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