• 第一个servlet小程序


    第一个servlet小程序

    com.fry.servlet.HelloServlet

     1 package com.fry.servlet;
     2 
     3 import javax.servlet.ServletException;
     4 import javax.servlet.http.HttpServlet;
     5 import javax.servlet.http.HttpServletRequest;
     6 import javax.servlet.http.HttpServletResponse;
     7 import java.io.IOException;
     8 import java.io.PrintWriter;
     9 
    10 public class HelloServlet extends HttpServlet {
    11 
    12     @Override
    13     protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    14         System.out.println("接收到get请求!!!");
    15         PrintWriter out=resp.getWriter();
    16         resp.setContentType("text/html;charset=utf-8");
    17         out.println("<strong>服务器已经接收到get请求!!!!!!</strong><br>");
    18     }
    19 
    20     @Override
    21     protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    22         System.out.println("接收到post请求!!!");
    23     }
    24 }

    index.jsp

     1 <%--
     2   Created by IntelliJ IDEA.
     3   User: user
     4   Date: 2017/10/31
     5   Time: 13:46
     6   To change this template use File | Settings | File Templates.
     7 --%>
     8 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
     9 <html>
    10   <head>
    11     <title>$Title$</title>
    12   </head>
    13   <body>
    14   欢迎访问我的第一个JSP。<br>
    15   <a href="hi">get请求</a>
    16   </body>
    17 </html>

    WEB-INF/web.xml

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
     3          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     4          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
     5          version="3.1">
     6     <servlet>
     7         <servlet-name>helloServlet</servlet-name>
     8         <servlet-class>com.fry.servlet.HelloServlet</servlet-class>
     9     </servlet>
    10     <servlet-mapping>
    11         <servlet-name>helloServlet</servlet-name>
    12         <url-pattern>/hi</url-pattern>
    13     </servlet-mapping>
    14 </web-app>

     目录结构

  • 相关阅读:
    奇异值分解(SVD)详解
    深度学习中常用的优化方法
    一年了,走了一些弯路,是时候回归了,介绍下深度学习中常见的降低过拟合的方法
    softmax与logistic关系
    Java [Leetcode 387]First Unique Character in a String
    Java [Leetcode 384]Shuffle an Array
    Java [Leetcode 167]Two Sum II
    用stack实现min stack
    bootstrap, boosting, bagging 几种方法的联系
    一道常被人轻视的前端JS面试题
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/7761796.html
Copyright © 2020-2023  润新知