照着打的报错了 请问什么原因?

来源:1-3 手工编写第一个Servlet

大秧歌

2016-03-28 17:13

jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <h1>1111</h1>
    <hr>
    <a href="yuiop/Helloworld">q</a>
</body>
</html>

java

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.catalina.connector.Response;

public class Helloworld extends HttpServlet {

 @Override
 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  // TODO Auto-generated method stub
  System.out.println("1234");
  PrintWriter out = response.getWriter();
  out.println("dsadsadsadsadsaa");
 }

 @Override
 protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  // TODO Auto-generated method stub
  
 }
   
}

xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>yuiop</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
     <servlet>
         <servlet-name>Helloworld</servlet-name>
         <servlet-class>yuiop</servlet-class>
     </servlet>
     <servlet-mapping>
         <servlet-name>Helloworld</servlet-name>
         <url-pattern>/yuiop/Helloworld</url-pattern>
     </servlet-mapping>
    
</web-app>

写回答 关注

3回答

  • qq_知乎上的键盘党_03280996
    2016-04-27 20:54:09
    已采纳

      <servlet-class>yuiop</servlet-class>  这句错了。不是yuiop而是yuiop.Helloworld

    大秧歌

    非常感谢!

    2016-05-23 15:40:38

    共 1 条回复 >

  • 寂Mo聆听
    2016-03-31 16:14:20

    你这么牛逼, 还发什么问题,

    共 1 条回复 >

  • 寂Mo聆听
    2016-03-29 11:33:29

      <servlet-class>yuiop</servlet-class>


    类写错了。

    大秧歌

    我会了 并不是那样

    2016-03-31 15:56:13

    共 2 条回复 >

JAVA遇见HTML——Servlet篇

本门课程在JSP课程的基础上,深入介绍Servlet的基础知识

160614 学习 · 1029 问题

查看课程

相似问题