【发布时间】:2013-06-01 01:18:12
【问题描述】:
我的动态web模块版本是3.0,tomcat我的tomcat版本是7.0。
我不知道为什么当我导航到页面 localhost:8080/SimpleProject 时它看不到我的 servlet XD。
当我导航到 localhost:8080/SimpleProject/firstservlet 时,我收到一条错误消息,上面写着 the requested resource is not available!
这是我的 servlet:
@WebServlet(description = "the first servlet", urlPatterns = { "/firstservlet" })
public class FirstServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// response.setContentType("text/html");
PrintWriter writer = response.getWriter();
writer.println("<h1>Why can't See<h1>");
}
我没有在 web.xml 上做任何事情,因为我知道在 3.0 版本中,url 映射在 servlet 中。
这是我的文件安排 :)
【问题讨论】:
-
您的上下文(根路径)是您的战争名称(以“.war”结尾),除非您在 context.xml 文件中专门将其设置为其他内容。
-
你能分享你的 web.xml 吗?
-
@ShadowCreeper 我已经这样做了。仍然请求的资源不可用
-
@F.H.当你将一个 html 文件放在你的战争的根目录中时,你能用你的浏览器点击它吗?
http://localhost:8080/SimpleProject/index.html例如? -
@ShadowCreeper 是的,我做到了...
标签: java