operamasks url传参 乱码, operamasks xhtml页面url 传参 中文乱码

页面一wew.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "" "">
<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
 xmlns:w="http://www.apusic.com/jsf/widget" xmlns:layout="http://www.apusic.com/jsf/layout"
 xmlns:h="http://java.sun.com/jsf/html" xmlns:ajax="http://www.apusic.com/jsf/ajax"
 renderKitId="AJAX">
 <w:head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 </w:head>
 <w:page title="Insert title here">
           
   <w:iframe id="frame1" style="width: 100%;height: 100%;" name="content1" frameborder="no"></w:iframe>

 </w:page>
</f:view>

 

对应WewBean ,红色部分很重要,不然会出现乱码

 

package com;

import java.io.Serializable;

import org.operamasks.faces.annotation.BeforeRender;
import org.operamasks.faces.annotation.Bind;
import org.operamasks.faces.annotation.ManagedBean;
import org.operamasks.faces.annotation.ManagedBeanScope;
import org.operamasks.faces.component.html.impl.UIIFrame;
/**
 *
 * This managed bean is generated automatically
 */
@ManagedBean(name="wewBean", scope=ManagedBeanScope.SESSION)
public class WewBean implements Serializable {
 @Bind
 private UIIFrame frame1;
 
 @BeforeRender
 public void init(boolean isPost) throws Exception {
   if (frame1.getSrc() == null || "".equals(frame1.getSrc())) {
    frame1.setSrc("wew1.xhtml?terminalId="+java.net.URLEncoder.encode("中文", "utf-8"));
    frame1.load(frame1.getSrc());
         }
 }
}

 

页面二wew1.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "" "">
<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
 xmlns:w="http://www.apusic.com/jsf/widget" xmlns:layout="http://www.apusic.com/jsf/layout"
 xmlns:h="http://java.sun.com/jsf/html" xmlns:ajax="http://www.apusic.com/jsf/ajax"
 renderKitId="AJAX">
 <w:head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 </w:head>
 <w:page title="Insert title here">
         <h:outputText id="paramvalue"></h:outputText>
 </w:page>
</f:view>

 

对应Wew1Bean

package com;

import java.io.Serializable;
import java.util.Map;

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.operamasks.faces.annotation.BeforeRender;
import org.operamasks.faces.annotation.Bind;
import org.operamasks.faces.annotation.ManagedBean;
import org.operamasks.faces.annotation.ManagedBeanScope;
import org.operamasks.faces.annotation.SaveState;
/**
 *
 * This managed bean is generated automatically
 */
@ManagedBean(name="wew1Bean", scope=ManagedBeanScope.SESSION)
public class Wew1Bean implements Serializable {
    @Bind
 @SaveState
 private String paramvalue = "";

    @BeforeRender
 public void init(boolean isPost) throws Exception {
     Map<String, String> valueMap = FacesContext.getCurrentInstance()
     .getExternalContext().getRequestParameterMap();
  String param = valueMap.containsKey("terminalId") ? String
     .valueOf(valueMap.get("terminalId")) : null;
  System.out.println(param);
  paramvalue = param;
  
 }
}

 

这样就好了!如果你有更好的传参方法,谢谢共同奉献!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值