一. “show”方法未传参,返回多个函数使用LIST
实现关联表查询
mapper
<select id="show" parameterType="java.lang.Integer" resultType="com.spring.demo.model.Travel">
SELECT
*
FROM
application_form a,t_travel b
WHERE
a.travel_id=b.travel_id AND a.user_id=#{userId} //多条件时需要传参的放在后面
</select>
Service
List<Travel> show(Integer userId);
//记住把参数写进去
Dao
List<Travel> show(@Param("userId") Integer userId);
实现层
@Override
public List<Travel> show(Integer userId) {
List<Travel> travel=TravelDao.show(userId);
return travel;
}
controller层
@GetMapping("show")
public ResponseEntity show(Integer userId){
return ResponseEntity.ok(travelService.show(userId));
}
二. 动态添加报名参加的旅游项目,实现 “show”方法
**1.**动态添加
function show(){
$.ajax({
url: 'http://localhost:8085/Travel/show?userId='+xx,
type: 'GET',
success:function (data) {
let dataHtml = "";
**********************************************************************************************
for(var i=0;i<data.length;i++){
let itemHtml = `<tr onclick="trClick(this)"><td>${data[i].viewName}</td><td>${data[i].money}</td><td>${data[i].location}</td></tr>`;
dataHtml += itemHtml;
}
**********************************************************************************************
$('#travelTableBody').empty().append(dataHtml);//Div内容是通过url页面进行动态添加的,需要先清除tbody内容
}
})
}
2. trClick方法 js和css结合 使鼠标点击经过位置变红,为tr添加class
加粗样式
四. console
1、console.log 用于输出普通信息
2、console.info 用于输出提示性信息
3、console.error用于输出错误信息
4、console.warn用于输出警示信息
5、console.debug用于输出调试信息