In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Xiaobian to share with you JSP page Chinese parameter transfer get and post method how to use, I believe most people still do not know how to use, so share this article for your reference, I hope you read this article after a great harvest, let us go to understand it together!
In projects, we often encounter the need to pass Chinese characters in JSP page transitions. There are two main ways to do this.
◆URL method
For example:
http://website/test1.jsp? act=add&type= apple ¶m=%20D%20B
◆FORM mode
For example:
﹤form name=test mehtod="post" input type=hidden name=text2 value="Chinese" input type=text name=text1 input type=submit value=submit/form
We will provide solutions to correct Chinese transmission for these two cases respectively.
JSP page Chinese parameter transmission 1: URL mode
For example:
http://website/test1.jsp? act=add&type= apple ¶m=%20D%20B
Generally speaking, we rarely write parameters in Chinese directly in URL, such as "type= apple" in the example. If this happens, we just need to do a simple conversion on our receive parameters page.
JSP page Chinese parameter transfer implementation code test1.jsp:(main part)
﹤%@ page language="java" import="java.util.* " pageEncoding="gb2312"%﹥ ﹤% String type = request.getParameter("type"); String result = new String(type.getBytes("iso-8859-1"), "gb2312"); out.println(result); %﹥
A more common practice is to encode Chinese characters in URLs into characters like type=%20D%20B.
JSP page Chinese parameter transfer implementation code MyJsp1.jsp:
﹤%@ page language="java" import="java.util.* " pageEncoding="gb2312"%﹥ ﹤%@ page import="java.net.* " %﹥ ﹤a href='./ MyJsp2.jsp? act= %=URLEncoder.encode("Chinese very good =-")%$>'> test/a>
JSP page Chinese parameter transfer code MyJsp2.jsp
﹤%@ page language="java" import="java.util.* " pageEncoding="gb2312"%﹥ ﹤%@ page import="java.net.* " %﹥ String tempVal = URLDecoder.decode(request.getParameter("act")); out.println(new String(tempVal.getBytes("ISO-8859-1"), "gb2312"));
JSP page Chinese parameter transmission 2: FORM mode
Please note that we are only discussing the Chinese case in the form of
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.