<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. API对接中经常会出现的签名获取,这只是某一种,仅供给有需要的人参考

    要求: 1.对所有传入参数(含系统参数和接口参数)按照字段名的 ASCII 码从小到大排序(字典序)后,使用 URL 键值对的格式.(即 key1=value1&key2=value2…)拼接 ...

  2. (9) tomcat中实现同一虚拟机中所有应用程序单点登录SSO

  3. 第二章:systemverilog声明的位置

    1.package 定义及从package中导入定义(***) verilog中,对于变量.线网.task.function的声明必须在module和endmodule之间.如果task被多个modu ...

  4. python 装饰器模拟京东登陆

    要求: 1.三个页面:主页面(home).书店(book).金融页面(finance)2.有两种登陆方式:主页面和书店页面使用京东账户登陆,金融页面使用微信账户登录2.输入:1 ,进入主页面,以此类推 ...

  5. Leetcode 229.求众数II

    求众数II 给定一个大小为 n 的数组,找出其中所有出现超过 ⌊ n/3 ⌋ 次的元素. 说明: 要求算法的时间复杂度为 O(n),空间复杂度为 O(1). 示例 1: 输入: [3,2,3] 输出: ...

  6. PatentTips - Wear Leveling for Erasable Memories

    BACKGROUND Erasable memories may have erasable elements that can become unreliable after a predeterm ...

  7. CodeIgniter框架的缓存原理分解

    用缓存的目的:(手册上叙述如下,已经写得很清楚了) Codeigniter 支持缓存技术,以达到最快的速度. 尽管CI已经相当高效了,但是网页中的动态内容.主机的内存CPU 和数据库读取速度等因素直接 ...

  8. mySQL windows 服务

    https://www.jizhuba.com/kejiyouxi/20171001/6006.html

  9. python学习之-- 面向对象

    面向对象(简写:OOP) 面向对象编程定义:利用类和对象来创建各种模型,来实现对真实世界的描述. 优点:使程序更容易理解和维护以及扩展代码. 类定义:用来描述具有相同的属性和方法的对象的集合.(简单讲 ...

  10. Codechef-CHEFPRAD(找事件点+贪心)

    题意: 定义一个函数maxMatching(A,B,y),其输入包含两个整数数组 A 和 B 以及一个整数 y,返回一个整数. 记数组 A 的大小为 N,数组 B 的大小为 M.考虑一个由 {a1, ...