代码:
Title
这是小滴课堂 freemaker整合index.html页面
payAppid ${setting}
package com.example.Maven.Project.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import java.io.Serializable;
@Configuration
@PropertySource(value="classpath:pay.properties")
public class WXConfig implements Serializable {
@Value("${wxpay.appid}")
private String payAppid;
@Value("${wxpay.secret}")
private String paySecret;
@Value("${wxpay.mechid}")
private String payMechId;
public String getPayAppid() {
return payAppid;
}
public void setPayAppid(String payAppid) {
this.payAppid = payAppid;
}
public String getPaySecret() {
return paySecret;
}
public void setPaySecret(String paySecret) {
this.paySecret = paySecret;
}
public String getPayMechId() {
return payMechId;
}
public void setPayMechId(String payMechId) {
this.payMechId = payMechId;
}
}
package com.example.Maven.Project.controller;
import com.example.Maven.Project.config.WXConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Controller
@RequestMapping("tpl")
public class FreeMarkerController {
@Autowired
private WXConfig wxConfig;
@GetMapping("freemaker")
public String index1(ModelMap modelMap){
modelMap.addAttribute("setting",wxConfig);
//不用加后缀,因为配置文件里面已经指定了后缀
return "fm/index";
}
}
#微信支付的appid
wxpay.appid=w23432432432
#支付秘钥
wxpay.secret=sfwerefwefqwed
#微信支付商户号
wxpay.mechid=324324