SELECT
TOP 5
shares_id,
shares_content,
shares_name,
shares_time,
shares_url,
shares_title
FROM
shares
WHERE
(
shares_id NOT IN (
SELECT
TOP (0 * 5) shares_id
FROM
shares
ORDER BY
shares_id
)
)
ORDER BY
shares_id
一直显示没有传入pageSize这个参数
图为xml里的配置
<select id="selectByExample" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
SELECT
TOP #{pageSize}
shares_id,shares_content,shares_name,shares_time,shares_url,shares_title
FROM
shares
<where>
(
shares_id NOT IN (
SELECT
TOP (#{pageSize} * #{startRow}) shares_id
FROM
shares
ORDER BY
shares_id
)
)
</where>
ORDER BY
shares_id
</select>
service层就省略啦
下图为控制层的部分代码
public String jsonArr(HttpServletRequest request, HttpServletResponse response) throws Exception {
Integer a = 0;
Integer b = 5;
//返回到浏览器时需要的编码格式
response.setCharacterEncoding("UTF-8");
//建立json对象对java对象进行转换转换成json格式的对象
List<Shares> shares = sharesService.selectByExample(a,b);
//通过构造函数进行封装对象
JSONArray json = JSONArray.fromObject(shares);
System.out.println(dateFormat.format(new Date()));
String s = json.toString(4);
//对tomcat的编码进行改变
String s1 = new String(s.getBytes("UTF-8"),"ISO-8859-1");
return s1;
}
急急急...........
|
|