ssm前端jsp提交数据到后台controller

  • 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>&nbsp;&nbsp;
		<a href="video/videoUpdate?fileId=${list.fileId}&currentPage=${page.currentPage}">修改</a>&nbsp;&nbsp;
		<a href="video/videoDelete?fileId=${list.fileId}&currentPage=${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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值