日期:2014-05-19  浏览次数:20646 次

servelt的部署小问题。。。
1:TOMCAT能够正常启动。。浏览器可正常访问localhost:8080。。。
2: 我想访问WEB项目下的 index.jsp的页面。。
  我的URL是 http://localhost:8080, 报错404
3: 我想访问WEB项目下的 servlet界面
  我的URL是 http://localhost:8080/url-pattern 报错404

问题: 怎么正常访问 是不是我的URL有问题。。。
麻烦 介绍解释下。。。

------解决方案--------------------
Java code
index.jsp是不是放到你的项目目录下 ? 需要放到你的项目目录下

比如你的目录为test ,则需要放到 webapps/test/index.jsp

http://localhost:8080/test/index.jsp

我想访问WEB项目下的 servlet界面 ? 没看明白什么意思

web.xml中配置servlet

<servlet>
    <servlet-name>loginServlet</servlet-name>
    <servlet-class>cai.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>loginServlet</servlet-name>
    <url-pattern>/login</url-pattern>
</servlet-mapping>

则 : http://localhost:8080/test/login (你的项目为test)

------解决方案--------------------
要注意你的项目名字,你的url地址中没有项目名字,项目必须先发布后在运行,其他我看没问题