输入查询条件查询能够显示第一页查询结果,但是点击翻页出错,
Required String parameter 'filename' is not present
参数无法获取,不知什么原因,求大神
jsp页面代码
<script language="javascript" type="text/javascript" src="<%=request.getContextPath() %>/My97DatePicker/WdatePicker.js"></script>
<%
HttpSession s = request.getSession();
%>
<%String s1=s.getAttribute("pagenum").toString();
String s2=s.getAttribute("pagesize").toString();
String s3=s.getAttribute("pagenow").toString();
String s4=s.getAttribute("num").toString();
int pagenum=Integer.parseInt(s1);
int pagesize=Integer.parseInt(s2);
int pagenow=Integer.parseInt(s3);
int pagenow2=Integer.parseInt(s3)+1;
int listnum=Integer.parseInt(s4);
int liststep=5;//显示页码数
if (pagenum < pagenow) {
pagenow = pagenum;//如果分页变量大总页数,则将分页变量设计为总页数
}
if (pagenow <=0) {
pagenow = 1;//如果分页变量小于1,则将分页变量设为1
}
else if (pagenow >0) {
pagenow = pagenow+1;//如果分页变量小于1,则将分页变量设为1
}
int listbegin = (pagenow - (int) Math.ceil((double) liststep / 2));//从第几页开始显示分页信息
if (listbegin < 1) { //当前页-(总显示的页列表数/2)
listbegin = 1;
}
int listend = (pagenow + liststep / 2)-1;//分页信息显示到第几页//当前页+(总显示的页列表数/2)
if (listend > pagenum) {
listend = pagenum + 1;
}
if(listnum<=10)
{
listend=1;}
if(listend-listbegin+1>pagenum)
{
listend=pagenum;}
if(listend>pagenum)
{
listend=pagenum;}
%>
<h4 align="center">上传任务管理</h4>
${pageaction}
<form action="upload/searchByFileName2/<%=0 %>" method="post">
<table border="1" cellspacing="0" align="center">
<tr>
<td colspan="2" align="center">查询</td>
</tr>
<tr>
<td width="450px" align="center">文件名称:<input type="text" name="filename" value=${filename} ></td>
<td width="450px" align="center">
文件类型:<select name="filetype" >
<option value="txt">txt</option>
<option value="jpg">jpg</option>
</select>
</td>
</tr>
<tr>
<td align="center" >
上传时间从:<input name="start" type="text" style="width: 180px;" onFocus="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"> </td>
<td align="center">
至:<input name="stop" type="text" style="width:180px;" onFocus="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" /> </td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="查询" style="width:150px;height: 25px" />
<input type="reset" value="重置" style="width:150px;height: 25px" >
</td>
</tr>
</table>
<font color="red"> ${errormessage}</font>
<br>
<table border="1px" cellpadding="0" cellspacing="0" align="center">
<tr>
<th ><input type="checkbox" name="all" value="ds"/></th>
<th >id</th>
<th >文件名</th>
<th >文件大小</th>
<th >文件类型</th>
<th >上传时间</th>
<th >文件描述</th>
<th >执行时间</th>
<th >运行结果</th>
<th >操作</th>
</tr>
<c:forEach var="upload" items="${upload}">
<tr>
<td width="45px"><input type="checkbox" value="${upload.id}" name="single"/></td>
<td width="45px">${upload.id}</td>
<td width="235px">${upload.filename}</td>
<td>${upload.filesize}</td>
<td>${upload.filetype}</td>
<td>${upload.uploaddate}</td>
<td>${upload.des}</td>
<td>${upload.runtime}</td>
<td>${upload.result}</td>
<td> <a href="">编辑</a> <a href="">删除</a><br /> </td>
</tr>
</c:forEach>
<tr>
<td align="right" colspan="10">
当前第:<%=pagenow%>页/共<%=pagenum %>页 显示<%=pagesize %>条/共<%=listnum %>条
</td>
</tr>
<tr>
<td align="center" colspan="10">
<% if (pagenow > 1) {
%> <a
href="${pageContext.request.contextPath}/${pageaction}/<%=pagenow-2 %>.html"
style="text-decoration:none"> <%
out.println("上一页");
}%> </a> <%for(int i=listbegin;i<=listend;i++)
{
pagenow=i;
%>
<a href="${pageContext.request.contextPath}/${pageaction}/<%=pagenow-1%>.html"
style="text-decoration:none" >
<%
if(i==pagenow2)
out.println("<font color='red'>["+i+"]</font> ");
else
out.println("["+i+"] ");
}
%>
</a>
<% if (pagenow !=pagenum)
{ %> <a
href="${pageContext.request.contextPath}/${pageaction}/<%=pagenow2 %>.html"
style="text-decoration:none"> <%
if(listnum!=0)
out.println("下一页");
}%> </a>
</td>
</tr>
</table>
</form>
</body>
</html>
jsp页面
controller代码
@RequestMapping(value="/searchByFileName2/{pagenow}")
public ModelAndView searchByFilename(HttpServletRequest request,@RequestParam String filename,@RequestParam String filetype,@RequestParam String start,@RequestParam String stop, ModelMap mod) throws ParseException
{
WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();
ServletContext application = webApplicationContext.getServletContext();
String n=(String) application.getAttribute("name");
System.out.println("sssssssssss "+n);
System.out.println("***************filename"+filename);
System.out.println("***************start"+start);
System.out.println("***************stop"+stop);
System.out.println("***************filetype"+filetype);
ModelAndView modelAndView=new ModelAndView("user/uploadWithPage");
if(start.equals("")&!stop.equals(""))
{
mod.addAttribute("errormessage", "上传日期不能为空");
return modelAndView;
}
if(!start.equals("")&stop.equals(""))
{
mod.addAttribute("errormessage", "上传日期不能为空");
return modelAndView;
}
Page<Upload> uploa=null;
if(filename.equals("")&start.equals("")&stop.equals(""))
{
uploa=uploadService.findUploadByUsernameAndFiletype(n, filetype, 0, pagesize);
}
else if(start.equals("")&stop.equals(""))
{
uploa=uploadService.findUploadByUsernameAndFilenameAndFiletype(n, filename, filetype, 0, pagesize);
}
else if(filename.equals("")&!start.equals("")&!stop.equals(""))
{
uploa=uploadService.findUploadByUsernameAndFileTypeAndUploaddate(n, filetype, start, stop, 0, pagesize);
}
else if(!filename.equals("")&!start.equals("")&!stop.equals(""))
{
uploa=uploadService.findUploadByAll(n, filename, filetype, start, stop, 0, pagesize);
}
else
{
mod.addAttribute("errormessage", "上传日期不能为空");
}
//当前页查询的记录数
pageitems=uploa.getNumberOfElements();
//查询出的总记录数
itemsnum=(int)uploa.getTotalElements();
//总页数
pagenum=uploa.getTotalPages();
HttpSession session = getSession();
session.setAttribute("pagenum", pagenum);
session.setAttribute("pagesize", pagesize);
session.setAttribute("num", itemsnum);
session.setAttribute("pagenow", pagenow);
session.setAttribute("filename", filename);
session.setAttribute("filetype", filetype);
session.setAttribute("start", start);
session.setAttribute("stop", stop);
mod.addAttribute("filename", filename);
List<Upload> u = uploa.getContent();
if(u.size()==0)
{
mod.addAttribute("errormessage", "该文件不存在");
return modelAndView;
}
mod.addAttribute("pageaction", "upload/searchByFileName2");
modelAndView.addObject("upload",u);
return modelAndView;
}