Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JeeSpringCloud
Commits
44ad5f47
"src/vscode:/vscode.git/clone" did not exist on "1e5c102f7df8141ee7d2ca22e824a87a33acbc0e"
Commit
44ad5f47
authored
Oct 22, 2018
by
HuangBingGui
Browse files
no commit message
parent
7fa8137a
Changes
41
Hide whitespace changes
Inline
Side-by-side
JeeSpringCloud/src/main/java/com/jeespring/modules/cms/web/front/WeixinController.java
0 → 100644
View file @
44ad5f47
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a>All rights reserved.
*/
package
com.jeespring.modules.cms.web.front
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.cms.utils.WiexinSignUtil
;
/**
* 测试Controller
* @author JeeSpring
* @version 2014-02-28
*/
@Controller
@RequestMapping
(
value
=
"${frontPath}/weixin"
)
public
class
WeixinController
extends
AbstractBaseController
{
/**
*
* @param signature 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
* @param timestamp 时间戳
* @param nonce 随机数
* @param echostr 随机数
* @return
*/
@RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
String
get
(
String
signature
,
String
timestamp
,
String
nonce
,
String
echostr
,
HttpServletRequest
request
)
{
System
.
out
.
println
(
"=============================================== get start"
);
for
(
Object
o
:
request
.
getParameterMap
().
keySet
()){
System
.
out
.
println
(
o
+
" = "
+
request
.
getParameter
((
String
)
o
));
}
System
.
out
.
println
(
"=============================================== get end"
);
// 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败
if
(
WiexinSignUtil
.
checkSignature
(
signature
,
timestamp
,
nonce
))
{
return
echostr
;
}
return
""
;
}
@RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
String
post
(
String
signature
,
String
timestamp
,
String
nonce
,
String
echostr
,
HttpServletRequest
request
)
{
System
.
out
.
println
(
"=============================================== post start"
);
for
(
Object
o
:
request
.
getParameterMap
().
keySet
()){
System
.
out
.
println
(
o
+
" = "
+
request
.
getParameter
((
String
)
o
));
}
System
.
out
.
println
(
"=============================================== post end"
);
StringBuilder
result
=
new
StringBuilder
();
result
.
append
(
"<xml>"
+
"<ToUserName><![CDATA[toUser]]></ToUserName>"
+
"<FromUserName><![CDATA[fromUser]]></FromUserName>"
+
"<CreateTime>12345678</CreateTime>"
+
"<MsgType><![CDATA[text]]></MsgType>"
+
"<Content><![CDATA[你好]]></Content>"
+
"</xml>"
);
return
result
.
toString
();
}
}
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment