operamasks url传参 乱码, operamasks xhtml页面url 传参 中文乱码
2010-11-05 10:34
351 查看
页面一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;
}
}
这样就好了!如果你有更好的传参方法,谢谢共同奉献!
<?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;
}
}
这样就好了!如果你有更好的传参方法,谢谢共同奉献!
相关文章推荐
- asp.net 页面通过URL传参中文乱码的三种解决方案
- 通过url方式传参jsp页面中文乱码
- 为什么前端页面encodeURI(url)两次,可以避免后台中文字符乱码
- C# asp.net页面通过URL参数传值中文乱码问题解决办法
- jsp利用表单跳转到另一个jsp页面传参时中文显示乱码
- URL传参中文乱码encodeURI、UrlDecode
- C# Url传参中文乱码
- URL 中文传参,JAVA后台 request.getParameterMap()乱码的解决办法
- Java在web页面上中文URL乱码解决
- get请求中url传参中文乱码问题--集锦
- url 中文传参 乱码问题
- 页面URL传递中文乱码
- jsp传参时若Url为中文时的乱码问题
- asp.net页面通过URL参数传值中文乱码问题解决办法
- java 页面url传值中文乱码的解决方法
- get请求中url传参中文乱码问题
- 关于js中文传参url乱码问题
- flash用url传传参给php中文乱码问题
- 解决页面之间相互传参中文乱码问题(收集)
- 处理url传参中文乱码问题