映射servlet怎么总不成功呀?帮帮忙!

Paripatetic 2006-01-26 12:31:40
我的servlet的名字是HelloWorld
将.class文件放到...\ROOT\WEB-INF\classes 里
也设置了web.xml:
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping>

浏览器http://localhost:1776/servlet/HelloWorld
里显示resource not avavilble
到底哪里错了呢?
...全文
302 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
xzgyb 2006-01-26
  • 打赏
  • 举报
回复
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>HelloWorld</servlet-class>

</servlet>

这个设没
Paripatetic 2006-01-26
  • 打赏
  • 举报
回复
终于搞定了 不知道是我的机器有问题还是....

应该把两个invoker直接换成类名
再在server.xml里改一下comtext里的path="/ROOT" docBase="ROOT"(或自己的文件路径)

唉~ 真实让人失望
这么个小问题折腾我一晚上
gernett21 2006-01-26
  • 打赏
  • 举报
回复
1:你的类的package是什么,在classes中要按正确的目录结构存放class文件;

2:在web.xml中要按顺序书写<servlet>和<servlet-mapping>

3:servlet-class中要写清类路径

4:注意大小写
Paripatetic 2006-01-26
  • 打赏
  • 举报
回复
你们的tomcat的设置都哪里该了?
除了:
/conf/server.xml里的port
/webapps/ROOT/WEB-INF/web.xml里添加mapping

还有哪里呀?
Paripatetic 2006-01-26
  • 打赏
  • 举报
回复
晕了 还是不行呀
访问主页都不行了 错误:
type Status report

message No Context configured to process this request

description The server encountered an internal error (No Context configured to process this request) that prevented it from fulfilling this request.

我的web.xml文件:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>

<!-- JSPC servlet mappings start -->

<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping>

<!-- JSPC servlet mappings end -->

</web-app>
Paripatetic 2006-01-26
  • 打赏
  • 举报
回复
无奈了........
我再重装一下
可能我的设置乱了
weizijia 2006-01-26
  • 打赏
  • 举报
回复
不好意思上面的是我的小弟弟给我捣乱
我本来就没看这条,我去WC了回来就看见了上面的
我小弟弟说要交管理员删除我的id好叫我不上csnd了
而是和他玩
weizijia 2006-01-26
  • 打赏
  • 举报
回复
妈的
weizijia 2006-01-26
  • 打赏
  • 举报
回复
内是我妈的
Trainsp0tting 2006-01-26
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright 2004 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>


<!-- JSPC servlet mappings start -->

<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping>

<!-- JSPC servlet mappings end -->

</web-app>
Paripatetic 2006-01-26
  • 打赏
  • 举报
回复
不行啊
把你的也放里面了
连tom-cat都启动不了啦

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧