标签:odi get url 指定 explorer pac 珍惜 long tps
礼悟:
好好学习多思考,尊师重道存感恩。叶见寻根三二一,江河湖海同一体。
虚怀若谷良心主,愿行无悔给最苦。读书锻炼强身心,诚劝且行且珍惜。
javaEE:7
javaSE:1.8
JSTL:1.2.2
server:tomcat 8.5
explorer:Firefox
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>MyHttpServlet</servlet-name> <servlet-class>jizuiku.web.servlet.MyHttpServlet</servlet-class><!-- 执行的是这个类 --> <init-param> <param-name>minNum</param-name> <param-value>10</param-value> </init-param> <init-param> <param-name>maxNum</param-name> <param-value>100</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>MyHttpServlet</servlet-name> <!-- 两个name 相应就好 --> <url-pattern>/MyHttpServletDemo</url-pattern><!-- 访问的是这个路径 --> </servlet-mapping> </web-app>
代码
package jizuiku.web.servlet;
import javax.servlet.http.HttpServlet;
/**
* 继承HttpServlet后,没重写doGetdoPost()
*
* @author 给最苦
* @version V17.10.20
*/
public class MyHttpServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
}
使用Get方式访问指定网页 效果
index.jsp的代码
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
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>
This is my JSP page. <br>
<form action="/Day09/MyHttpServletDemo" method="post">
<button type="submit" value="submit"></button>
</form>
</body>
</html>
使用Post的方式访问指定网页 效果

学习资源:itcast和itheima视频库。如果您有公开的资源,可以分享给我的话,用您的资源学习也可以。
博文是观看视频后,融入思考写成的。博文好,是老师讲得好。博文坏,是 给最苦 没认真。
JavaWeb基础 HttpServlet 浏览器405 继承而且没重写的doGetdoPost()却被调用
标签:odi get url 指定 explorer pac 珍惜 long tps
原文地址:http://www.cnblogs.com/jizuiku/p/7707132.html