首页 > 代码库 > JSP页面之间互相传值
JSP页面之间互相传值
页面一:
<s:if test="#list.sourceId==1">
<a
href="http://www.mamicode.com/${pageContext.request.contextPath}/jsp/tiaozhuan.jsp?goodsName=
<s:property value="http://www.mamicode.com/#list.goodsName" />&photoUrl=<s:property value="http://www.mamicode.com/#list.photoUrl" />
&goodsPrice=<s:property value="http://www.mamicode.com/#list.goodsPrice" />&unitCost=<s:property value="http://www.mamicode.com/#list.unitCost" />
&zhekou=<s:property value="http://www.mamicode.com/#list.zhekou" />&monsales=<s:property value="http://www.mamicode.com/#list.monsales" />
&weblinkurl=<s:property value="http://www.mamicode.com/#list.weblinkurl" />&sourceId=淘宝"
target="_blank">
</s:if>
<s:if test="#list.sourceId==2">
<a
href="http://www.mamicode.com/${pageContext.request.contextPath}/jsp/tiaozhuan.jsp?goodsName=
<s:property value="http://www.mamicode.com/#list.goodsName" />&photoUrl=<s:property value="http://www.mamicode.com/#list.photoUrl" />
&goodsPrice=<s:property value="http://www.mamicode.com/#list.goodsPrice" />&unitCost=<s:property value="http://www.mamicode.com/#list.unitCost" />
&zhekou=<s:property value="http://www.mamicode.com/#list.zhekou" />&monsales=<s:property value="http://www.mamicode.com/#list.monsales" />
&weblinkurl=<s:property value="http://www.mamicode.com/#list.weblinkurl" />&sourceId=天猫"
target="_blank">
</s:if>
页面二:<%=new String(request.getParameter("monsales").getBytes( "iso-8859-1"), "UTF-8")%>
常见问题:
在本地测试没问题,放到服务器之后url传输的中文乱码。
解决方案:<%=new String(request.getParameter("monsales").getBytes( "UTF-8"),"UTF-8")%>
因为我页面一传输的就是utf-8 格式的数据,这里接收的时候还用它进行解码,并转换成utf-8就OK了
JSP页面之间互相传值