成功捷徑,貴在堅持
          人為善,福雖未至禍已遠離; 人為惡,禍雖未至福已遠離

          ??????昨天遇到一個問題讓我困惑了半天,window.open("url?param="+paramvalue)傳遞參數出現亂碼,以前從沒有遇到過這種問題,在客房端顯示是正常的,可是到服務端就是亂碼,不管用什么方式轉碼都不行,經過和同事一翻調試,最后想到了一個js在客戶端轉碼的函數,escape(str);但是傳到服務端仍然是亂碼,必須在服務端進行解碼。服務端執行request.setCharacterEncoding("utf-8");或GBK,這樣傳過來的參數就不用轉碼也是中文了。唉,總算功夫沒有白費!
          ?window.open("WindowCustomerListAction?username="+encodeURIComponent(form1.name.value), "customerList", "width=550,height=250,scrollbars=yes,resizable=yes,status=yes");
          服務端
          public class WindowCustomerListAction extends AbstractAction{
          ?/**
          ? * (non-Javadoc)
          ? *
          ? * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector,
          ? *????? org.apache.cocoon.environment.SourceResolver, java.util.Map,
          ? *????? java.lang.String, org.apache.avalon.framework.parameters.Parameters)
          ? */
          ?public Map act(Redirector redirector, SourceResolver resolver,
          ???Map objectMode, String source, Parameters param) throws Exception {
          ??// TODO Auto-generated method stub
          ??Request request = ObjectModelHelper.getRequest(objectMode);
          ??String userName = request.getParameter("username")==null?"":request.getParameter("username").trim();
          ??//獲得要顯示的頁碼
          ??String showpage = request.getParameter("showpage") == null ? "1"
          ????: request.getParameter("showpage");
          ??//客戶信息接口
          ??ThProcessCustomerDAO customerDao = (ThProcessCustomerDAO) AppSqlConfig
          ????.getDaoManagerInstance().getDao(ThProcessCustomerDAO.class,
          ??????"sqlmap");
          ??//獲得客戶列表
          ??ThProcessCustomerExample example = new ThProcessCustomerExample();?
          ??example.setName("%"+userName+"%");
          ??example.setName_Indicator(ThProcessCustomerExample.EXAMPLE_LIKE);??
          ??List customerlist = customerDao.selectByExample(example);??
          ??int count = customerlist.size();
          ??
          ??//分頁
          ??PageControl pageControl = new PageControl();
          ??pageControl.setPageSize(10);
          ??pageControl.setRowCount(count);
          ??pageControl.setRequestUrl("WindowCustomerListAction?userName="+userName+"&showpage=");
          ???????
          ??pageControl.setShowPage(Integer.parseInt(showpage));

          ??request.setAttribute("pageControl", pageControl);
          ??request.setAttribute("customerlist", customerlist);
          ??return null;
          ?}
          }

          posted on 2006-08-02 08:18 選寶網an9 閱讀(2898) 評論(2)  編輯  收藏 所屬分類: JAVA

          FeedBack:
          # re: window.open("url?param="+paramvalue)亂碼[未登錄]
          2009-06-01 12:25 | michael
          URL encoding 一下就好了
            回復  更多評論
            
          # re: window.open("url?param="+paramvalue)亂碼
          2009-07-24 18:16 | huliang
          不會吧?你這樣就有用  回復  更多評論
            
          主站蜘蛛池模板: 常宁市| 焦作市| 凤台县| 黄平县| 黄大仙区| 平山县| 呈贡县| 阳曲县| 新化县| 金塔县| 卢湾区| 来宾市| 田林县| 新宾| 且末县| 娱乐| 香港 | 和硕县| 陆良县| 盐亭县| 沐川县| 济阳县| 兰西县| 巴林左旗| 平泉县| 湾仔区| 安多县| 余江县| 曲阳县| 罗甸县| 磐安县| 肃北| 新乡市| 丽江市| 方正县| 长垣县| 平舆县| 遵义县| 景泰县| 泽州县| 金湖县|