1.将项目部署到tomcat之外
通过Tomcat目录下的
conf/Catalina/localhost/
新建projectname.xml的方式,可以将项目部署到tomcat的外部,该文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<ContextdocBase="/Volumes/workspace/20130908/projectname/"
reloadable="true">
</Context>
检查web.xml红色部分,避免类不被tomcat访问
tomcat7能正常访问classes
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0" Metadata-complete="true">
<display-name>web服务器</display-name>
<description>
使用Servlet实现HelloWorld的例子
</description>
<servlet>
<servlet-name>Servers</servlet-name>
<servlet-class>com.web.Servers</servlet-class>
<init-param>
<param-name>version</param-name>
<param-value>1.0</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<url-pattern>/Servers</url-pattern>
</servlet-mapping>
<servlet-name>Config</servlet-name>
<servlet-class>com.web.Config</servlet-class>
<url-pattern>/Config</url-pattern>
<servlet-name>Notice</servlet-name>
<servlet-class>com.web.Notice</servlet-class>
<url-pattern>/Notice</url-pattern>
<servlet-name>Login</servlet-name>
<servlet-class>com.web.Login</servlet-class>
<url-pattern>/Login</url-pattern>
<servlet-name>Shop</servlet-name>
<servlet-class>com.web.Shop</servlet-class>
<url-pattern>/Shop</url-pattern>
<servlet-name>Verify</servlet-name>
<servlet-class>com.web.Verify</servlet-class>
<url-pattern>/Verify</url-pattern>
<session-config>
<session-timeout>100</session-timeout>
</session-config>
</web-app>
tomcat7不能正常访问classes
<?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"
xmlns:web_1="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"
version="2.5">
</web-app>