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

          ??????昨天遇到一個問題讓我困惑了半天,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 閱讀(2904) 評論(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
          不會吧?你這樣就有用  回復  更多評論
            
          主站蜘蛛池模板: 安平县| 句容市| 安吉县| 崇义县| 杨浦区| 冕宁县| 凉城县| 宜春市| 津市市| 阿拉尔市| 遂宁市| 平罗县| 广灵县| 延吉市| 曲靖市| 汕尾市| 澄迈县| 高青县| 樟树市| 梨树县| 邮箱| 和平区| 吉木乃县| 广平县| 资源县| 老河口市| 锡林郭勒盟| 柳河县| 赫章县| 海林市| 罗平县| 寻乌县| 托克逊县| 汶川县| 本溪| 福鼎市| 祁东县| 炎陵县| 仪陇县| 陕西省| 昌都县|