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】

    下图为运行结果

  • 相关阅读:
    基础
    条件语句/变量和基本数据类型
    编程语言介绍
    asp.net中log4net使用方法
    web布到服务器上出错
    《转》IEnumerable、IEnumerator两个接口的认识
    异步ADO.NET
    Session的使用
    AJAX参数及各种HTTP状态值
    简易的抓取别人网站内容
  • 原文地址:https://www.cnblogs.com/mtsl/p/4332433.html
Copyright © 2011-2022 走看看