搭建maven开发环境,使用spring boot简易架构进行如下开发
Controller层
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class CustomerController {
public static void main(String[] args) {
SpringApplication.run(CustomerController.class, args);
}
@RequestMapping(value="/hello",produces="text/plain;charset=UTF-8")
String sayHello(){
String requestStr = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential"
+ "&appid=xxxxxxx&secret=xxxxxxxxxx";
String tok="";
//截取微信返回的token值
String[] token=HttpXmlClient.sendGet(requestStr,"").split("\"");
for(int i=0;i