我尝试研究网络服务器编程基础。
我在 Ubuntu 12.04 上安装了 tomcat 7(当我输入时一切正常,myIp:8080
我真的看到了正确的 tomcat 页面)。
并创建了简单的结构:
在apache-tomcat-7.0.42/webapps
=> 这里创建Beer-v1
progect => 到这个文件夹文件WEB-INF
夹和form.html
.
代码form.html
:
<html>
<body>
<h1 align=”center”>Beer Selection Page</h1>
<form method=”POST”
action=”SelectBeer.do”>
Select beer characteristics<p>
Color:
<select name=”color” size=”1”>
<option value=”light”> light </option>
<option value=”amber”> amber </option>
<option value=”brown”> brown </option>
<option value=”dark”> dark </option>
</select>
<br><br>
<center>
<input type=”SUBMIT”>
</center>
</form>
</body>
</html>
进入WEB-INF web.xml
。
代码web.xml
:
<web-app xmlns=”http://java.sun.com/xml/ns/j2ee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”
version=”2.4”>
<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>
当我bin/startup.sh
进入apache-tomcat-7.0.42
文件夹时,我看到下一个输出:
root@nazar-desctop:/usr/local/tomcat/apache-tomcat-7.0.42# bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-7.0.42
Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-7.0.42
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-7.0.42/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/apache-tomcat-7.0.42/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-7.0.42/bin/tomcat-juli.jar
在浏览器中输入后http://localhost:8080/Beer-v1/form.html
- 我看到:
HTTP Status 404 - /Beer-v1/form.html。
我无法弄清楚出了什么问题。
更新:
的内容catalina.out
- 你可以在这里
看到
和localhost.2013-09-12.log
:
Sep 12, 2013 9:17:26 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Sep 12, 2013 9:17:26 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Sep 12, 2013 9:17:27 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@d47feb3')
Sep 12, 2013 9:17:34 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Sep 12, 2013 9:17:34 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Sep 12, 2013 9:17:35 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@27c76b8d')
Sep 12, 2013 9:17:35 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Sep 12, 2013 9:17:35 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Sep 12, 2013 9:21:12 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Sep 12, 2013 9:21:12 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Sep 12, 2013 9:21:14 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@41fb43a2')
Sep 12, 2013 9:21:17 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Sep 12, 2013 9:21:17 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Sep 12, 2013 9:30:38 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Sep 12, 2013 9:30:38 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Sep 12, 2013 9:30:38 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@30ce9337')
Sep 12, 2013 9:30:39 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Sep 12, 2013 9:30:39 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Sep 12, 2013 9:44:30 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Sep 12, 2013 9:44:30 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Sep 12, 2013 9:44:30 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@357c4ab7')
Sep 12, 2013 9:44:31 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Sep 12, 2013 9:44:31 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
如何解决这个麻烦?