微信小程序与servlet交互

学了一段时间的小程序,现在记录一下

之前写了jsp和servlet之间是怎么传输数据和返回数据的,那么微信小程序和servlet是怎么进行交互的,前端怎么进入后台。
开发准备:
微信开发工具:4090
IDE: Eclipse Mars Release (4.5.0)
jdk:1.8.0_171
Tomcat:v7.0
MySQL:5.7(mysql-connector-java-5.1.26)

后台项目结构
在这里插入图片描述
新建com.syrinx.order包,结构如上图

1、建立连接类DBUtil

package com.syrinx.order;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
public class DBUtil {
	static   private String classDriver;
	static   private String url;
	static   private String userName;
	static   private String passWord;
    static {
        try {
            ClassLoader classLoader = DBUtil.class.getClassLoader()
            InputStream is = classLoader.getResourceAsStream("jdbc.properties");  //通过字节输入流读取配置文件
            Properties props = new Properties();
            props.load(is); //加载配置文件
        //得到配置文件中的值
            classDriver = props.getProperty("classDriver");
            url = props.getProperty("url");
            userName = props.getProperty("userName");
            passWord = props.getProperty("passWord");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
	public static Connection getConnection() {
        Connection conn = null;
            try {
				Class.forName(classDriver);
				conn = DriverManager.getConnection(url, userName, passWord);
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return conn;
    }
}


jdbc.propertices

#userName=root
#passWord=
classDriver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/syrinxsysorder?useUnicode=true&characterEncoding=UTF-8

2、建立user实体类

package com.syrinx.modules.video;
public class VideoBean {
	private int   id;
	
	private String title;
	private String videoUrl;
	private String imageUrl;
	private String downloadTimes;
	private String previewTimes;
	private String createTime;
	private String updateTime;
	private String headLine;
	private int  type_id;
	
	public int getType_id() {
		return type_id;
	}
	public void setType_id(int type_id) {
		this.type_id = type_id;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getHeadLine() {
		return headLine;
	}
	public void setHeadLine(String headLine) {
		this.headLine = headLine;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getVideoUrl() {
		return videoUrl;
	}
	public void setVideoUrl(String videoUrl) {
		this.videoUrl = videoUrl;
	}
	public String getImageUrl() {
		return imageUrl;
	}
  • 8
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值