开发者社区 问答 正文

JFinal分页查询,翻页传参报错? 400 报错

JFinal分页查询,翻页传参报错? 400 报错

@VikingZ 你好,想跟你请教个问题:我是根据您的Jfinal自动封装参数的文章http://my.oschina.net/vikingz/blog/144374,写的一个分页查询,但是在查询后,在翻页时,就出错了,不知道是什么原因,可以帮忙看下吗。

/**
		 * 分页查询
		 */
		public void plist(){	
			       String sqlCondition = " 1=1";
			        Map<String,String[]> paraMap = getParaMap();//获取条件参数
			        String[] paraStr = sdImpl.makePara(studentSearch, "studentSearch", paraMap);
			        sqlCondition += paraStr[0];
			        setAttr("studentPage", Student.dao.paginate(getParaToInt(0,1), 5, "select *", "from student where" + sqlCondition));
			        if(paraMap.size()>0){
			        setAttr("searchCon", paraStr[1]);
			        }else{
			        	setAttr("searchCon", "");
			        }
			        render("/paginateIndex.html");
		}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生列表</title>
<link media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<h3 style=" text-align:center;">学生列表</h3>
<form action="${ctx}/Student/plist" method="post">
   <table border="1"  style="border-collapse:collapse; width:800px;" align=" center">
            <tr>
                <td>姓名</td>
                <td><input type="text" name="studentSearch.studentname"></td>
                <td>性别</td>
                <td><input type="text" name="studentSearch.studentsex"></td>
            </tr>
            </table>
               <button type=" submit"   value="查询" >查询</button>
</form>
<br>
<table border="1"  style="border-collapse:collapse; width:800px;" align=" center">
            <tr>
                <td>姓名</td>
                <td>年龄</td>
                <td>性别 </td>
                <td>操作/<a
            </tr>
            <#list studentPage.getList() as student>
            <tr>
                <td> ${student.studentname}</td>
                <td>${student.studentage}</td>
                <td>
               <#if student.studentsex="1">
                     男
                 <#else>
                     女
                   </#if>
               </td>
                <td>
                    <a
                    <a
                </td>
            </tr>
            </#list>
        </table>
        <#include "/common/_paginate.html" />
	<@paginate  currentPage=studentPage.pageNumber totalPage=studentPage.totalPage actionUrl="${ctx}/Student/plist/"  urlParas=searchCon/>
</body>
</html>





展开
收起
爱吃鱼的程序员 2020-06-05 12:36:35 486 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    引用来自“hexin20117”的答案

    引用来自“wang_liran”的答案

    404,url肯定有不对

    我觉得你提交参数有问题,“&”这个字符在这个位置有点莫名其妙,因为“&”是参数连接符,一般在“?”号后面,可是你这里连“?”都没有。

    我大概知道你是对plist提交一个XX=2&studentSearch.sthudentsex=1这样两个参数,建议好好参照JFinal文档,看看getPara()方法是怎么使用的

    刚学习Jfinal,对jfinal的多个条件传参,不是很明白。因为分页时默认url=../plist/2/是这样.如果我加多个条件传参可以需要怎么写,我试了 url=../plist/2?&student.studentsex=1也不行

    按照你的做法把&去掉,&是参数连接符,?后面只有一个参数就不需要连接符


    url=../plist/2?student.studentsex=1

    ######另外,这个已经不是JFinal的内容了,建议看看URL基本构成,这是基础中的基础,加油######什么错误?错误也不贴.还问个毛问题,还想让别人通过你的代码给你分析啊...######你好,页面报错,发上去了,oschina刚用,不太会,见谅######报错信息贴上来看看######你好,页面报错,发上去了,oschina刚用,不太会,见谅,刚学习jfinal######

    就是查询后,点击翻页,就报错了,连方法都没进去 @loyal
    @wang_liran 帮忙看下,谢谢

    ######

    404,url肯定有不对

    我觉得你提交参数有问题,“&”这个字符在这个位置有点莫名其妙,因为“&”是参数连接符,一般在“?”号后面,可是你这里连“?”都没有。

    我大概知道你是对plist提交一个XX=2&studentSearch.sthudentsex=1这样两个参数,建议好好参照JFinal文档,看看getPara()方法是怎么使用的

    ######哪跑出来的&???在jfinal里基本不会出现这个.######

    引用来自“wang_liran”的答案

    404,url肯定有不对

    我觉得你提交参数有问题,“&”这个字符在这个位置有点莫名其妙,因为“&”是参数连接符,一般在“?”号后面,可是你这里连“?”都没有。

    我大概知道你是对plist提交一个XX=2&studentSearch.sthudentsex=1这样两个参数,建议好好参照JFinal文档,看看getPara()方法是怎么使用的

    刚学习Jfinal,对jfinal的多个条件传参,不是很明白。因为分页时默认url=../plist/2/是这样.如果我加多个条件传参可以需要怎么写,我试了 url=../plist?2&student.studentsex=1也不行
    ######

    引用来自“loyal”的答案

    哪跑出来的&???在jfinal里基本不会出现这个.
    就是根据条件分页查询后,在翻页,要传参数到后台,再取值啊
    ######

    引用来自“wang_liran”的答案

    引用来自“hexin20117”的答案

    引用来自“wang_liran”的答案

    404,url肯定有不对

    我觉得你提交参数有问题,“&”这个字符在这个位置有点莫名其妙,因为“&”是参数连接符,一般在“?”号后面,可是你这里连“?”都没有。

    我大概知道你是对plist提交一个XX=2&studentSearch.sthudentsex=1这样两个参数,建议好好参照JFinal文档,看看getPara()方法是怎么使用的

    刚学习Jfinal,对jfinal的多个条件传参,不是很明白。因为分页时默认url=../plist/2/是这样.如果我加多个条件传参可以需要怎么写,我试了 url=../plist/2?&student.studentsex=1也不行

    按照你的做法把&去掉,&是参数连接符,?后面只有一个参数就不需要连接符


    url=../plist/2?student.studentsex=1

    嗯,谢谢,明白了。
    ######wang_liran 的答案是对的,是url的问题
    2020-06-05 12:36:49
    赞同 展开评论
问答分类:
问答地址: