我尝试创建存档:
jar cvf mywarfile.war *
这确实创建了一个war文件.但是,当我在tomcat上部署这个战争时,它似乎不起作用. Tomcat会自动将war文件解压缩到一个目录,但它不能通过Web服务器获得.我想这与我的战争不包含目录WEB-INF和meta-inf有关.
有没有一种简单的方法可以将静态客户端Web应用程序转换为可部署的war文件?
解决方法 为了在tomcat上部署内容,必须包含一个文件/WEB-INF/web.xml.下面是我用来通过tomcat部署一些静态内容的web.xml示例.<?xml version="1.0" enCoding="UTF-8"?><web-app> <servlet> <servlet-name>default</servlet-name> <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> <init-param> <param-name>deBUG</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>Listings</param-name> <param-value>false</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>Jsp</servlet-name> <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> <init-param> <param-name>fork</param-name> <param-value>false</param-value> </init-param> <load-on-startup>3</load-on-startup> </servlet> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.Json</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.csv</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.Js</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.HTML</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.CSS</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.jpg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.jpeg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.png</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.Js</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.gif</url-pattern> </servlet-mapping> <mime-mapPing> <extension>csv</extension> <mime-type>text/csv</mime-type> </mime-mapPing> <mime-mapPing> <extension>CSS</extension> <mime-type>text/CSS</mime-type> </mime-mapPing> <mime-mapPing> <extension>Js</extension> <mime-type>application/JavaScript</mime-type> </mime-mapPing> <mime-mapPing> <extension>HTML</extension> <mime-type>text/HTML</mime-type> </mime-mapPing> <security-constraint> <web-resource-collection> <web-resource-name>Restricted URLs</web-resource-name> <url-pattern>/</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> <!-- Default page to serve --> <welcome-file-List> <welcome-file>index.HTML</welcome-file> </welcome-file-List></web-app>总结
以上是内存溢出为你收集整理的web-server – 从静态web目录创建tomcat war文件全部内容,希望文章能够帮你解决web-server – 从静态web目录创建tomcat war文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)