zoukankan      html  css  js  c++  java
  • Java web项目搭建系列之二 Jetty下运行项目

    在项目pom.xml文件中添加Jetty运行配置

    在pom.xml文件project节点下插入如下代码:

        <build>
            <plugins>
                <plugin>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>maven-jetty-plugin</artifactId>
                    <version>6.1.26</version>
                    <configuration>
                        <scanIntervalSeconds>10</scanIntervalSeconds>
                        <contextPath>/hello</contextPath>
                    </configuration>
                </plugin>
            </plugins>
            <finalName>
        hello
        </finalName>
        </build>

    添加web.xml文件:

    在【src】→【main】→【webapp】→【WEB-INF】文件夹下添加【web.xml】文件

    web.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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">
    
    </web-app>

    国际惯例—Hello,World!:

    在【webapp]目录下添加【index.html】文件,内容如下

    <!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=UTF-8">
    <title>HelloMaven</title>
    </head>
    <body>
        <h1>hello,world!</h1>
    </body>
    </html>

    运行,查看结果:

    在【HelloMaven】项目上,右击【Run As】→【Run Jetty】

    下图为运行结果

  • 相关阅读:
    VS2015安装水晶报表
    C# 通过java生成的RSA公钥加密和解密
    T4代码生成器
    产品开发- DFX
    读《31天学会CRM项目开发》记录3
    读《31天学会CRM项目开发》记录2
    读《31天学会CRM项目开发》记录1
    产品开发
    产品开发
    机器视觉
  • 原文地址:https://www.cnblogs.com/mtsl/p/4332433.html
Copyright © 2011-2022 走看看