Generate .war file from web app containing just HTML, CSS & JavaScript

前端 未结 2 1157
清酒与你
清酒与你 2021-02-14 12:22

I am trying to create a war file that will be deployed on a web/application server.

The source files of the app are purely HTML, CSS, and JavaScript. There is a separat

相关标签:
2条回答
  • 2021-02-14 12:32

    If you are creating a war file, then you are deploying on a Java based web application server, something like Tomcat or Wildfly.

    If you are using eclipse, you can do so by New > Dynamic Web Project (maybe name it foo-bar), click next, next and finish. Then open that foo-bar project and create your css and js folders under WebContent like so.

    \WebContent\css
    \WebContent\js
    \WebContent\index.html
    \WebContent\foo-bar.html
    

    You can right click the foo-bar project > Export > Web WAR file.

    When you deploy it on say Tomcat, you can test to access your static content like so

    http://localhost:8080/foo-bar/css/foo-bar.css
    http://localhost:8080/foo-bar/js/foo-bar.js
    http://localhost:8080/foo-bar/foo-bar.html
    

    Hope this helps.

    0 讨论(0)
  • 2021-02-14 12:53

    This is extremely simple:

    1. Create a folder
    2. Add a src/main/webapp folder
    3. Add all of your HTML, CSS and JS files to the src/main/webapp folder
    4. Add an empty web.xml file to the src/main/webapp/WEB-INF directory.
    5. add a maven pom.xml
    6. add the maven-war-plugin to your pom.xml, with the following configuration:

      <!--  create the war -->
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
        </configuration>
      </plugin>
      
    7. run mvn clean install!

    0 讨论(0)
提交回复
热议问题