Skip to content

Commit da667ab

Browse files
committed
使用spring新提供的注解
1 parent 8fc463b commit da667ab

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/java/com/github/binarywang/demo/wechat/controller/WechatController.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
import org.slf4j.Logger;
55
import org.slf4j.LoggerFactory;
66
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.PostMapping;
79
import org.springframework.web.bind.annotation.RequestBody;
810
import org.springframework.web.bind.annotation.RequestMapping;
9-
import org.springframework.web.bind.annotation.RequestMethod;
1011
import org.springframework.web.bind.annotation.RequestParam;
1112
import org.springframework.web.bind.annotation.ResponseBody;
1213
import org.springframework.web.bind.annotation.RestController;
@@ -30,8 +31,7 @@ public class WechatController {
3031
@Autowired
3132
private WxMpMessageRouter router;
3233

33-
@RequestMapping(method = RequestMethod.GET,
34-
produces = "text/plain;charset=utf-8")
34+
@GetMapping(produces = "text/plain;charset=utf-8")
3535
public @ResponseBody String authGet(
3636
@RequestParam(name = "signature",
3737
required = false) String signature,
@@ -54,8 +54,7 @@ public class WechatController {
5454
return "非法请求";
5555
}
5656

57-
@RequestMapping(method = RequestMethod.POST,
58-
produces = "application/xml; charset=UTF-8")
57+
@PostMapping(produces = "application/xml; charset=UTF-8")
5958
public @ResponseBody String post(@RequestBody String requestBody,
6059
@RequestParam("signature") String signature,
6160
@RequestParam("timestamp") String timestamp,

0 commit comments

Comments
 (0)