标签:html 4.01 xtend except final UI not desc username sele
HttpServlet超类在java构建路径中没有找到 https://jingyan.baidu.com/article/6c67b1d69a37a02787bb1ee2.html =============================================== servlet处理http请求1 客户端发送http请求的方式 HttpServletRequest接口概述 获取http请求参数的方法 客户端发送http请求的方式 地址栏直接输入URL 超链接的href指定的URL 表单标签form的action指定的URL javascript的location.href指定URL HttpServletRequest接口 继承自ServletRequest接口,处理http请求 封装了http请求的请求url,请求参数,请求报文等信息 由容器实现,开发中直接从doMethod的参数中获取其实例 获取http请求参数的方法 从以do开头的方法中直接获取。 servlet处理http请求2 获取表单控件中的参数 处理console乱码,临时地加入下面一行 request.setCharacterEncoding("utf-8"); 空字符串 用户名与密码未填写时 null 单选框未选中时 空指针 复选框一个都不选时
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <a href="Servlet1?name=tom&name=jack&gender=male">请求1</a> <form action="Servlet2" method="post"> <input type="text" name="username"/><br /> <input type="password" name="userpwd"/><br /> <input type="radio" name="gender" value="f" />女 <input type="radio" name="gender" value="m" />男<br /> <input type="checkbox" name="favors" value="football" />足球 <input type="checkbox" name="favors" value="music" />音乐 <input type="checkbox" name="favors" value="swim" />游泳<br /> <select name="cities"> <option value="1">内蒙</option> <option value="2">河南</option> <option value="3">河北</option> </select><br /> <textarea rows="3" cols="3" name="description"></textarea> <br /> <input type="submit" value="提交" /> </form> </body> </html>
package com.fgy; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/Servlet2") public class Servlet2 extends HttpServlet { private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("============================"); //临时地解决一下控制台中文乱码问题 request.setCharacterEncoding("utf-8"); String userName=request.getParameter("username"); System.out.println(userName); System.out.println(request.getParameter("userpwd")); System.out.println(request.getParameter("gender")); String[] favors=request.getParameterValues("favors"); if (favors != null) { for (String s : favors) { System.out.println(s); } } System.out.println(request.getParameter("cities")); System.out.println(request.getParameter("description")); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }
标签:html 4.01 xtend except final UI not desc username sele
原文地址:https://www.cnblogs.com/createyuan/p/9083090.html