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

          ??????昨天遇到一個問題讓我困惑了半天,window.open("url?param="+paramvalue)傳遞參數(shù)出現(xiàn)亂碼,以前從沒有遇到過這種問題,在客房端顯示是正常的,可是到服務(wù)端就是亂碼,不管用什么方式轉(zhuǎn)碼都不行,經(jīng)過和同事一翻調(diào)試,最后想到了一個js在客戶端轉(zhuǎn)碼的函數(shù),escape(str);但是傳到服務(wù)端仍然是亂碼,必須在服務(wù)端進(jìn)行解碼。服務(wù)端執(zhí)行request.setCharacterEncoding("utf-8");或GBK,這樣傳過來的參數(shù)就不用轉(zhuǎn)碼也是中文了。唉,總算功夫沒有白費(fèi)!
          ?window.open("WindowCustomerListAction?username="+encodeURIComponent(form1.name.value), "customerList", "width=550,height=250,scrollbars=yes,resizable=yes,status=yes");
          服務(wù)端
          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 選寶網(wǎng)an9 閱讀(2899) 評論(2)  編輯  收藏 所屬分類: JAVA

          FeedBack:
          # re: window.open("url?param="+paramvalue)亂碼[未登錄]
          2009-06-01 12:25 | michael
          URL encoding 一下就好了
            回復(fù)  更多評論
            
          # re: window.open("url?param="+paramvalue)亂碼
          2009-07-24 18:16 | huliang
          不會吧?你這樣就有用  回復(fù)  更多評論
            
          主站蜘蛛池模板: 天津市| 谷城县| 镇康县| 客服| 本溪市| 扶沟县| 岳普湖县| 巢湖市| 普兰县| 湾仔区| 安义县| 丁青县| 原平市| 湟源县| 类乌齐县| 喜德县| 成都市| 六安市| 辽宁省| 淮南市| 南皮县| 凉山| 九龙县| 志丹县| 福州市| 时尚| 老河口市| 芮城县| 华容县| 昌吉市| 宁明县| 建昌县| 黄梅县| 栾城县| 信丰县| 石屏县| 固阳县| 池州市| 寻乌县| 衡阳县| 武陟县|