<script type="text/javascript">
function show(){
var f="#wer中文测试";
f = encodeURIComponent(encodeURIComponent(f));
test.value = f;
var url = "servlet/Test?f="+f;
var rtv = showModalDialog(url,"","dialogWidth:820px; dialogHeight:620px; status:0;help:0;scrolling:auto");
}
</script>
<body><input id="test" value=""> <input type="button" value="TEST" onclick="show()" />
</body>
package com.yourcompany.struts.action;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.yourcompany.struts.form.TestForm; public class TestAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
TestForm testForm = (TestForm) form; response.setCharacterEncoding("UTF-8"); String name=testForm.getName();
String pwd=testForm.getPwd(); response.setCharacterEncoding("UTF-8");
String myname=request.getParameter("myname");
myname=URLDecoder.decode(myname, "UTF-8");
String mypwd=request.getParameter("mypwd");
mypwd=URLDecoder.decode(mypwd, "UTF-8"); System.out.println(name);
System.out.println(pwd);
System.out.println(myname);
System.out.println(mypwd); request.setAttribute("name", name);
request.setAttribute("pwd", pwd);
request.setAttribute("myname", myname);
request.setAttribute("mypwd", mypwd); return mapping.findForward("go");
}
}

encodeURIComponent的更多相关文章

  1. 结合实例详细介绍encodeURI()、encodeURIComponent()、decodeURI()、decodeURIComponent()使用方法

    在介绍encodeURI().encodeURIComponent().decodeURI().decodeURIComponent()方法前我们需要了解Global对象的概念:   Global(全 ...

  2. 简单明了区分escape、encodeURI和encodeURIComponent

    一.前言 讲这3个方法区别的文章太多了,但是大部分写的都很绕.本文试图从实践角度去讲这3个方法. 二.escape和它们不是同一类 简单来说,escape是对字符串(string)进行编码(而另外两种 ...

  3. js的encodeURIComponent与java的URLEncoder的区别

    js中的encodeURIComponent这个函数和java中的URLEncoder有少数不一样的.如下表格就是区别 ascii java js   + %20 ! %21 ! ' %27 ' ( ...

  4. JS中的decodeURIComponent和encodeURIComponent

    两个函数可以对特定函数生成的密码字符串进行解密操作,就可以生成为未解密的字符串 使用方法: //加密 encodeURIComponent("http://www.cnblogs.com/7 ...

  5. JavaScript URL编码转换函数 encodeURIComponent()

    encodeURIComponent()定义和用法 encodeURIComponent() 函数可把字符串作为 URI 组件进行编码. 语法:encodeURIComponent(URIstring ...

  6. escape,encodeURI,encodeURIComponent的区别

    escape是对字符串进行编码而另外两种是对URL. encodeURI方法不会对下列字符编码 ASCII字母 数字 ~!@#$&*()=:/,;?+'encodeURIComponent方法 ...

  7. escape(), encodeURI()和encodeURIComponent()(转)

      escape(), encodeURI()和encodeURIComponent()是在Javascript中用于编码字符串的三个常用的方法,而他们之间的异同却困扰了很多的Javascript初学 ...

  8. 关于 escape、encodeURI、encodeURIComponent

    参考资料:http://hi.baidu.com/flondon/item/983b3af35b83fa13ce9f3291   http://www.w3school.com.cn/js/jsref ...

  9. javascript中escape()、unescape()、encodeURI()、encodeURIComponent()、decodeURI()、decodeURIComponent()比较

    这些URI方法encodeURI.encodeURIComponent().decodeURI().decodeURIComponent()代替了BOM的escape()和unescape()方法.U ...

  10. js基础篇——encodeURI 和encodeURIComponent

    转自zccst的又一次掉进encodeURIComponent的坑里了 问题: ajax.get ( url+'?k1'=v1+'&k2'=v2+'&k3'=v3, ... ); 由于 ...

随机推荐

  1. KVM中存储的配置

    存储配置和启动顺序 QEMU提供了对多种块存储设备的模拟,包括IDE设备.SCSI设备.软盘.U盘.virtio磁盘等,而且对设备的启动顺序提供了灵活的配置. 1. 存储的基本配置选项 在qemu-k ...

  2. hdu4407Sum(容斥原理)

    http://acm.hdu.edu.cn/showproblem.php?pid=4407 Sum Time Limit: 2000/1000 MS (Java/Others)     Memory ...

  3. 比特币 3角对冲python代码

    3角对冲原理 基础货币 base, 兑换货币 quote, 中间货币 mid. 市场分为3个市场 p3: base_quote p2: quote_mid p1: quote_mid 代码逻辑 1, ...

  4. python_字符串类型

    1.在python中用单引号' ',双引号'' '',三引号'''  ''' 标注字符串类型. >>> name = "Alex Li" #双引号 >> ...

  5. django的基本操作流程

    pip   install django cd Desktop/课上代码02/ #进入到创建项目的目录   django-admin startproject 项目的名称  #创建项目   __ini ...

  6. mybatis完整sql调试

    问题描述 在使用mybatis进行开发的时候,由于可以动态拼接sql,这样大大方便了我们.但是也有一定的问题,当我们动态sql拼接的块很多的时候,我们要想从*mapper.xml中直接找出完整的sql ...

  7. Tomcat启动慢(运行shutdown.sh的时候报错)

    Using CATALINA_BASE: /usr/local/tomcatUsing CATALINA_HOME: /usr/local/tomcatUsing CATALINA_TMPDIR: / ...

  8. 一张图表,人人都能建立自己的AARRR运营模型

    每次跟同行聊运营,聊用户,聊产品,最后都会回到AARRR模型上来,这个用户全生命周期模型概括了互联网产品运营的5个关键环节. 获客是运营的基础,促进用户活跃才能让产品有生命力,提升留存减少流失让用户规 ...

  9. ajax传递参数给springmvc

    下面看一些传参的例子,基本涵盖了大部分的参数传递类型

  10. zoj 2109 FatMouse' Trade

    FatMouse' Trade Time Limit: 2 Seconds      Memory Limit: 65536 KB FatMouse prepared M pounds of cat ...