页面中的代码如下${requestScope.tradeType} 中取的上边form表单的值需要传递到action中进行参数查询分页。
<s:if test="pageNow!=intPageCount">
 <a href="<s:url includeParams="none" encode="false" action="ShopnoteAction" method="selShopno" >
        <s:param name="pageNow">%{intPageCount}</s:param>
        <s:param name="userPid"><s:property value="#session.user.userPid"/></s:param>
         <s:param name="tradeNumber">${requestScope.tradeNumber} </s:param>
        <s:param name="tradeType">${requestScope.tradeType} </s:param>
        <s:param name="yue">${requestScope.yue} </s:param>
        <s:param name="year">${requestScope.year} </s:param>
         <s:param name="tradeStatus">${requestScope.tradeStatus} </s:param>
         </s:url>">末页</a>
</s:if>
action中的代码如下。。
/**
 * 查询全部交易记录的方法
 * @return
 * @throws Exception
 */
public String selShopno() throws Exception {
String filePath="toShopno";//返回值
String tradeTime=year+"-"+yue;//设定时间
intRowCount=shopnoteService.search(userPid, tradeStatus, tradeTime, tradeNumber, tradeType).size();
        k=(intRowCount + pageSize - 1) / pageSize;
        intPageCount = (intRowCount + pageSize - 1) / pageSize;//计算出总页数
        if(pageNow<=1){
         i=0;
         pageNow=1;
        }
        if(pageNow >=intPageCount){
            pageNow=intPageCount;
            i = (pageNow -1)*pageSize;
        }
        if(pageNow<intPageCount && pageNow>1){
         i=(pageNow-1)*pageSize;
        }
        HttpServletRequest request = ServletActionContext.getRequest();
//        request.setAttribute("tradeType", tradeType);
//        String tradeType=(String)request.getAttribute("tradeType");
//        tradeType = new String(this.tradeType.getBytes("ISO-8859-1"),"UTF-8");
        System.out.println(tradeType+"===========================================");
listshop=shopnoteService.search(userPid, tradeStatus, tradeTime, tradeNumber,tradeType, i, pageSize);//联合查询
if(listshop.size()<1){
ActionContext.getContext().put("message", "<font color='red'>尊敬的用户,没有您要查询的信息!</font>");//设定页面返回信息
}
return filePath;
}
现在的问题是我的参数
${requestScope.tradeType} 是中文传到action是乱码。而我form表单提交则没有问题。分页传递参数的话是乱码
地址栏中的如下
tradeType=%E5%85%A8%E6%9C%88%E8%AE%A2%E9%98%85%E7%9A%84
action中的输出值如下。
??¨???è??é?????
请教各位大侠帮帮忙哈哈小弟没弄出来

解决方案 »

  1.   

    你的服务器里面是否设置了URIEncoding="UTF-8"?
      

  2.   

    因为服务器默认的url编码方式是与操作系统挂钩的.! 也就是GBK,而Struts2的默认编码是UTF-8, 所以它会把一串UTF-8的编码当GBK扔过去了.!
    改了以后就ok了.!
      

  3.   

    web服务器比如tomcat的server.xml里面加URIEncoding="UTF8"
    struts.xml;
    <struts>
    <constant name="struts.i18n.encoding" value="utf-8" />
      

  4.   

    哈哈谢谢啦解决啦是tomcat的问题嘿嘿。楼上的大哥。。这个早加啦(*^__^*) 嘻嘻我接着研究我那个参数隐藏去。。想把参数隐藏掉然后把地址栏的地址给伪静态。。
      

  5.   

    struts2配置默认就是这个,不用设置  服务器的要设