我依据《架构探险从零开始写javaweb框架》里的案列做。
IntelliJ-IDEA 2016.3.2
Tomcat7
这个是404截图
pom.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.donman
chapter1
1.0.0
war
UTF08
javax.servlet
javax.servlet-api
3.1.0
provided
javax.servlet.jsp
jsp-api
2.2
provided
javax.servlet
jst1
1.2
runtime
org.apache.maven.plugins
maven-compiler-plugin
3.3
1.6
1.6
org.apache.maven.plugins
maven-surefire-plugin
2.18.1
true
org.apache.tomcat.maven
tomcat7-maven-plugin
2.2
/${project.artifactId}
false
central
Maven Repository Switchboard
http://repo2.maven.org/maven2
web.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
hello.jsp
TitleHelloHelloServlet.java
package com.donman.chapter1;
import javax.jws.WebService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by lindi on 2017/1/2.
*/
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException{
DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String currentTime = dateformat.format(new Date());
req.setAttribute("currentTime", currentTime );
req.getRequestDispatcher("/WEB-INF/jsp/hello.jsp").forward(req,resp);
}
}
log:
C:UserslindiIdeaProjectsapache-tomcat-7.0.73bincatalina.bat run
[2017-01-03 12:59:51,566] Artifact chapter1:war exploded: Server is not connected. Deploy is not available.
Using CATALINA_BASE: "C:Userslindi.IntelliJIdea2016.3systemtomcatUnnamed_(1)_chapter1"
Using CATALINA_HOME: "C:UserslindiIdeaProjectsapache-tomcat-7.0.73"
Using CATALINA_TMPDIR: "C:UserslindiIdeaProjectsapache-tomcat-7.0.73temp"
Using JRE_HOME: "C:Program FilesAndroidAndroid Studio1jre"
Using CLASSPATH: "C:UserslindiIdeaProjectsapache-tomcat-7.0.73binbootstrap.jar;C:UserslindiIdeaProjectsapache-tomcat-7.0.73bintomcat-juli.jar"
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/7.0.73
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Nov 7 2016 21:27:23 UTC
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 7.0.73.0
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 10
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 10.0
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: amd64
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: C:Program FilesAndroidAndroid Studio1jrejre
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_76-release-b03
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: C:Userslindi.IntelliJIdea2016.3systemtomcatUnnamed_(1)_chapter1
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: C:UserslindiIdeaProjectsapache-tomcat-7.0.73
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcom.sun.management.jmxremote=
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcom.sun.management.jmxremote.port=1099
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcom.sun.management.jmxremote.ssl=false
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.rmi.server.hostname=127.0.0.1
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.util.logging.config.file=C:Userslindi.IntelliJIdea2016.3systemtomcatUnnamed_(1)_chapter1conflogging.properties
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=C:UserslindiIdeaProjectsapache-tomcat-7.0.73endorsed
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=C:Userslindi.IntelliJIdea2016.3systemtomcatUnnamed_(1)_chapter1
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=C:UserslindiIdeaProjectsapache-tomcat-7.0.73
一月 03, 2017 12:59:53 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.io.tmpdir=C:UserslindiIdeaProjectsapache-tomcat-7.0.73temp
一月 03, 2017 12:59:53 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: Loaded APR based Apache Tomcat Native library 1.2.10 using APR version 1.5.2.
一月 03, 2017 12:59:53 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
一月 03, 2017 12:59:55 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized (OpenSSL 1.0.2j 26 Sep 2016)
一月 03, 2017 12:59:55 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-apr-8080"]
一月 03, 2017 12:59:55 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-apr-8009"]
一月 03, 2017 12:59:55 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 2681 ms
一月 03, 2017 12:59:55 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
一月 03, 2017 12:59:55 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.73
一月 03, 2017 12:59:55 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-apr-8080"]
一月 03, 2017 12:59:55 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-apr-8009"]
一月 03, 2017 12:59:55 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 266 ms
Connected to server
[2017-01-03 12:59:55,741] Artifact chapter1:war exploded: Artifact is being deployed, please wait...
[2017-01-03 12:59:56,949] Artifact chapter1:war exploded: Artifact is deployed successfully
[2017-01-03 12:59:56,949] Artifact chapter1:war exploded: Deploy took 1,208 milliseconds
一月 03, 2017 1:00:05 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:UserslindiIdeaProjectsapache-tomcat-7.0.73webappsmanager
一月 03, 2017 1:00:06 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory C:UserslindiIdeaProjectsapache-tomcat-7.0.73webappsmanager has finished in 521 ms