- form表单提交数据
1.jsp页面
<form action="video/doVideoListByDate" method="post">
<input type="date" name="uploadTime" size="40" style="height: 40px; width: 70%;" >
<input type="submit" value="视频搜索">
</form>
controller层
@RequestMapping("doVideoListByDate")
public String videoListByUploadDate(String uploadTime,Model model){
List<FileEntity> fileEntities = fileservice.getFileByFileUploadTime(uploadTime);
model.addAttribute("fileEntity",fileEntities);
return "videoListByDate";
}
2.jsp注册页面
<form action="user/insertUser" method="post">
<fieldset>
<table style="background-color:#FFFFFF">
<tr style="height:30px;font-size:25px">
<td align="right" style="width:100%">注册52Player</td>
</tr>
<tr>
<td>姓名:</td>
<td><input type="text" name="userName" id="userName" placeholder="请输入姓名" size="40"/></td>
</tr>
<tr>
<tr>
<td>账号:</td>
<td><input type="text" name="uNo" id="uNo" placeholder="请输入账号" size="40"/></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="password" id="password" placeholder="请输入密码" size="40"/></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" id="confirmPassword" placeholder="请再次输入密码" size="40"/></td>
</tr>
<tr>
<td>用户类型:</td>
<td><select name="uType"size="1" id="uType">
<option value="2">普通用户</option>
</select>
</td>
</tr>
<tr style="background-color:#1ABC9C">
<td colspan="2" align="center" style="height:50px;">
<input type="button" id="saveButton" value="注册" uNo=style="height:50px;font-Size:20px" /><br>
</td>
</tr>
<tr>
<td id="result"></td>
</tr>
</table>
</fieldset>
</form>
controller层直接把form提交的name属性值封装成对应的entity实体类
@RequestMapping("insertUser")
public String insertUser(User user,Model model){
if (user != null) {
userService.insertUser(user);
}else {
System.out.println("输入无效值");
}
- jsp页面的链接向controller通过?uId=${}提交,多个参数中间使用&
<td align="center">
<button onclick="play('${list.path}')">播放</button>
<a href="video/videoUpdate?fileId=${list.fileId}¤tPage=${page.currentPage}">修改</a>
<a href="video/videoDelete?fileId=${list.fileId}¤tPage=${page.currentPage}" onclick="del(this)">删除</a>
</td>
controller层
@RequestMapping("videoUpdate")//jsp同时向controller传递里fileId和currentPage两个参数
public String videoUpdate(@RequestParam("fileId") Integer fileId,@RequestParam("currentPage") Integer currentPage,Model model,HttpSession session){
FileEntity fileEntity = fileservice.findByid(fileId);
session.setAttribute("currentPage", currentPage);//在他的返回页面里面封装一个参数,在他的跳转页面上可使用session.getAttribute("currentPage")获取到这个参数
model.addAttribute("video", fileEntity);
return "videoUpdate";
}
- jsp页面的a链接使用/${uId}传递
<tr>
<td colspan="9">
<span>共${page.totalDataCount}条记录,共${page.totalPage }页</span>
<a href="video/videoList/1">首页</a>
<c:if test="${page.currentPage!=1}">
<a href="video/videoList/${page.currentPage-1}">上一页</a>
</c:if>
<c:if test="${page.currentPage==1}">
<a href="javascript:void(0)">上一页</a>
</c:if>
<c:if test="${page.currentPage!=page.totalPage}">
<a href="video/videoList/${page.currentPage+1}">下一页</a>
</c:if>
<span>第${page.currentPage }页</span>
<c:if test="${page.currentPage==page.totalPage}">
<a href="javascript:void(0)">下一页</a>
</c:if> <a href="video/videoList/${page.totalPage}">尾页</a>
</td>
</tr>