java ssm框架调用微信,微信小程序实现前后台交互(后台使用ssm框架)

微信小程序前端代码 :

index.js中page的onload函数。

onLoad: function () {

wx.request({

url: 'http://localhost:8080/BaseProjectSSM/admin/clazz_table/list2',

method: 'post',

header: {

'content-type': 'application/json' // 默认值

},

success: res => {

console.log(res.data)

this.setData({

})

},

fail: res => {

console.log("失败")

}

})

if (app.globalData.userInfo) {

this.setData({

userInfo: app.globalData.userInfo,

hasUserInfo: true

})

} else if (this.data.canIUse){

// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回

// 所以此处加入 callback 以防止这种情况

app.userInfoReadyCallback = res => {

this.setData({

userInfo: res.userInfo,

hasUserInfo: true

})

}

} else {

// 在没有 open-type=getUserInfo 版本的兼容处理

wx.getUserInfo({

success: res => {

app.globalData.userInfo = res.userInfo

this.setData({

userInfo: res.userInfo,

hasUserInfo: true

})

}

})

}

},

微信控制台结果:

b1c3611b854e2b832a9c38446767022e.png

后台代码:

控制层:

@RequestMapping(value="/list2",method=RequestMethod.POST)

@ResponseBody

public MapgetList2(){

Mapret = new HashMap();

Listclazz1 = clazzService.findList2();

ret.put("clazzList2", clazz1);

return ret;

}

service.java文件

public ListfindList2();

serviceImpl.java文件

@Override

public ListfindList2() {

// TODO Auto-generated method stub

return clazzDao.findList2();

}

dao.java文件

public ListfindList2();

clazz.java实体类

package com.ischoolbar.programmer.entity.admin;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.List;

import org.springframework.stereotype.Component;

/**

* 课程实体

* @author whs

*

*/

@Component

public class Clazz {

private Long id;

private String clazzname;//课程名字

private Long categoryId;//分类id

private ClazzCategory clazzCategory;//课程类别

private Long addressId;//课程地址

private String teacher;//教师

private Date clazzTime;//上课时间

private Integer duration; //时长

private String weekday;//星期

private String cost;//费用

private String remark;//备注

public Long getId() {

return id;

}

public void setId(Long id) {

this.id = id;

}

public String getClazzname() {

return clazzname;

}

public void setClazzname(String clazzname) {

this.clazzname = clazzname;

}

public Long getCategoryId() {

return categoryId;

}

public void setCategoryId(Long categoryId) {

this.categoryId = categoryId;

}

public ClazzCategory getClazzCategory() {

return clazzCategory;

}

public void setClazzCategory(ClazzCategory clazzCategory) {

this.clazzCategory = clazzCategory;

}

public Long getAddressId() {

return addressId;

}

public void setAddressId(Long addressId) {

this.addressId = addressId;

}

public String getTeacher() {

return teacher;

}

public void setTeacher(String teacher) {

this.teacher = teacher;

}

public Date getClazzTime() {

return clazzTime;

}

public void setClazzTime(String clazzTime) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

try {

this.clazzTime = sdf.parse(clazzTime);

} catch (ParseException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public Integer getDuration() {

return duration;

}

public void setDuration(Integer duration) {

this.duration = duration;

}

public String getWeekday() {

return weekday;

}

public void setWeekday(String weekday) {

this.weekday = weekday;

}

public String getCost() {

return cost;

}

public void setCost(String cost) {

this.cost = cost;

}

public String getRemark() {

return remark;

}

public void setRemark(String remark) {

this.remark = remark;

}

}

mapper.xml文件

select * from clazz where 1 = 1

数据库:

af3c48606b8b8f52a355c59cb1cc655a.png

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值