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

          ??????昨天遇到一個問題讓我困惑了半天,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
          不會吧?你這樣就有用  回復  更多評論
            
          主站蜘蛛池模板: 环江| 鸡西市| 高陵县| 乌苏市| 喀喇| 定结县| 正安县| 库伦旗| 邵阳县| 扎赉特旗| 九龙县| 金湖县| 瓦房店市| 长宁县| 南溪县| 祁阳县| 梁平县| 稻城县| 甘洛县| 江陵县| 钟山县| 祁阳县| 永修县| 武邑县| 满城县| 宕昌县| 黑水县| 建湖县| 镇远县| 滕州市| 隆林| 咸宁市| 佛学| 龙门县| 鄂伦春自治旗| 安多县| 青冈县| 壤塘县| 中宁县| 阿城市| 吉水县|