HttpServletRequest getParameter 接收get方式传递的中文参数(tomcat8.5)
2017-10-27 17:36
603 查看
礼悟:
公恒学思合行悟,尊师重道存感恩。叶见寻根三返一,江河湖海同一体。
虚怀若谷良心主,愿行无悔给最苦。读书锻炼养身心,诚劝且行且珍惜。
工程目录结构
web.xml
Servlet类代码
index.jsp向相关页面提供Get请求
浏览器查看页面
控制台的输出
学习资源:itcast和itheima视频库。如果您有公开的资源,可以分享给我的话,用您的资源学习也可以。
博文是观看视频后,融入思考写成的。博文好,是老师讲得好。博文坏,是 给最苦 没认真。
公恒学思合行悟,尊师重道存感恩。叶见寻根三返一,江河湖海同一体。
虚怀若谷良心主,愿行无悔给最苦。读书锻炼养身心,诚劝且行且珍惜。
javaEE:7
javaSE:1.8
JSTL:1.2.2
server:tomcat 8.5
explorer:Chrome
os:windows7 x64
ide:MyEclipse 2017
javaSE:1.8
JSTL:1.2.2
server:tomcat 8.5
explorer:Chrome
os:windows7 x64
ide:MyEclipse 2017
工程目录结构
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <servlet> <servlet-name>MyServlet</servlet-name> <servlet-class>jizuiku.web.servlet.MyServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet</servlet-name> <url-pattern>/MyServlet</url-pattern> </servlet-mapping> </web-app>
Servlet类代码
package jizuiku.web.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * * * @author 给最苦 * @version V17.10.25 */ public class MyServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // tomcat7 的时候,还iso呢 // 8 默认 utf-8了 与时俱进 System.out.println(request.getParameter("name")); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } }
index.jsp向相关页面提供Get请求
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <a href="/Day10/MyServlet?name=博客园-给最苦">超链接</a> <form action="/Day10/MyServlet" method="post"> 名字:<input type="text" name="name"/> <input type="submit" value="提交" /> </form> </body> </html>
浏览器查看页面
控制台的输出
学习资源:itcast和itheima视频库。如果您有公开的资源,可以分享给我的话,用您的资源学习也可以。
博文是观看视频后,融入思考写成的。博文好,是老师讲得好。博文坏,是 给最苦 没认真。
相关文章推荐
- HttpServletRequest getParameterValues 接收get/post方式传递的多值参数
- HttpServletRequest setCharacterEncoding 接收post方式传递的中文参数
- A标签中传递的中文参数到Servlet 后台request.getParameter()接收时出现中文乱码
- tomcat_get方式传递中文参数乱码问题
- JQuery中Ajax的Post提交中文乱码、windows.location.href 中文汉字乱码和springmvc使用原生态HttpServletRequest接收参数中文乱码解决办法
- 后台通过HttpServletRequest对象获取页面表单传递过来的参数的方式
- 修改Tomcat默认编码消除get方式传递参数出现中文乱码
- springMVC参数的传递方式(1.通过@PathVariabl获取路径参数,2.@ModelAttribute获取数据,3.HttpServletRequest取参,4@RequestParam)
- 修改Tomcat默认编码消除get方式传递参数出现中文乱码
- springMVC参数的传递方式(1.通过@PathVariabl获取路径参数,2.@ModelAttribute获取数据,3.HttpServletRequest取参,4@RequestParam)
- AJAX对于JAVA接收HttpServletRequest和json字符串两种方式的传递写法
- http的get与post方式下的getParameter获取中文
- 利用Get方式传递中文参数
- HTTP AJAX POST请求中参数以form data和request payload形式在servlet中的获取方式
- HttpServletRequest. getParameter获取的参数格式
- bootstrap分页查询传递中文参数到后台(get方式提交)
- HttpServletRequest接收参数的几种方法
- HttpServletRequest request 获取form参数的两种方式
- Spring MVC Controller中解析GET方式的中文参数会乱码的问题(tomcat如何解码)
- Http协议参数传递中编码问题(Get/Post 方式)