Maven-java_web

2021/7/29 1:35:46

本文主要是介绍Maven-java_web,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

如何能够让一个东西自动帮我导入和配置这个jar包。

Maven项目架构管理工具

就是方便导入jar包

约定大于配置

1.配置环境变量

 

2.配置加速镜像

<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf>
<name>Nexus maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>


3.创建本地创库

localRepository

默认:用户/.m2/repository

<localRepository>D:\work\apache-maven-3.8.1\maven-repo</localRepository>

 

4.在idea使用maven

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

web xml设置映射:

 

 

 

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>
  <servlet>
    <servlet-name>helloServlet</servlet-name>
    <servlet-class>com.wang.servlet.HelloServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>helloServlet</servlet-name>
    <url-pattern>/wang</url-pattern>
  </servlet-mapping>
</web-app>

 

package com.wang.servlet;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloServlet extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Hello Worldddfdafdaf!</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Hello World!</h1>");
        out.println("</body>");
        out.println("</html>");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}

 



这篇关于Maven-java_web的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程