例如test.jsp页面代码:
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<base href="<%=basePath%>">
<title>新闻标题</title>
</head>
<body>
<a href="news?action=singleShow&id=1">新闻标题</a>
</body>
</html>
相应的web.xml中的配置是
<servlet>
<servlet-name>NewsServlet</servlet-name>
<servlet-class>serv.NewsServlet</servlet-class>
</servlet> <servlet-mapping>
<servlet-name>NewsServlet</servlet-name>
<url-pattern>/news</url-pattern>
</servlet-mapping>
然后在浏览器中输入http://localhost:8080/Test02/WebRoot/test.jsp便访问到test.jsp,点击test.jsp中的超链接,便出现了错误:
HTTP Status 404 - /Test02/news--------------------------------------------------------------------------------type Status reportmessage /Test02/newsdescription The requested resource (/Test02/news) is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.26其中Test02是我的项目名称,毕业设计马上就要交了,大家帮帮忙啊
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<base href="<%=basePath%>">
<title>新闻标题</title>
</head>
<body>
<a href="news?action=singleShow&id=1">新闻标题</a>
</body>
</html>
相应的web.xml中的配置是
<servlet>
<servlet-name>NewsServlet</servlet-name>
<servlet-class>serv.NewsServlet</servlet-class>
</servlet> <servlet-mapping>
<servlet-name>NewsServlet</servlet-name>
<url-pattern>/news</url-pattern>
</servlet-mapping>
然后在浏览器中输入http://localhost:8080/Test02/WebRoot/test.jsp便访问到test.jsp,点击test.jsp中的超链接,便出现了错误:
HTTP Status 404 - /Test02/news--------------------------------------------------------------------------------type Status reportmessage /Test02/newsdescription The requested resource (/Test02/news) is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.26其中Test02是我的项目名称,毕业设计马上就要交了,大家帮帮忙啊
解决方案 »
- 刚入职场,请各位前辈为小弟解惑...在线等....
- servlet跳转中文参数的问题。
- 为什么访问不了局域网里的项目?
- 多附件上传的问题,仿163,强人看下
- 操作伸缩表格中的文本框(做过这方面的朋友帮个忙).....急
- 好奇怪!明明正确而且在别的JSP中可用的UPDATE语句,在另一个JSP中就不管用!!!???
- Servlet.service() for servlet jsp threw exception
- 最早的富客户端技术applet为什么没有发展了?
- 怎样在Windows 2000下配置jdk1.3和tomcat 4.0?
- 拿radio值的问题
- struts求助
- ckeditor 浏览器兼容问题
<Context debug="0" docBase="F:/workspace/Test02/WebRoot" path="/Test02" reloadable="true" >
</Context>启动tomcathttp://localhost:8080/Test02/test.jsp 应该可以访问 ,然后在访问你的servlet
中的东西全部复制到C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\Test02\目录中个就可以了
你这里http://localhost:8080/Test02/WebRoot/test.jsp
HTTP Status 404 - /Test02/news
你这样试试<a href="WebRoot/news?action=singleShow&id=1">新闻标题</a>
我奇怪的是你好像是在WebRoot下面又建了一个WebRoot文件夹?