java环境,以及tomcat环境都正常
在webapps下自建jsp目录
jsp目录下有 WEB-INF ,同时编写了web.xml
可以访问jsp下的test.jsp现在弄了一个servlet
编译没有问题
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Test extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out=response.getWriter();
out.println("<html>;<body>;<h1>;This is a servlet test.</h1>;</body>;</html>;");
out.flush();
}
}
================分界线================
web.xml如下
<?xml version="1.0" encoding="ISO-8859-1"?>
<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>Test</servlet-name>
<servlet-class>Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/Test</url-pattern>
</servlet-mapping>
<!-- JSPC servlet mappings end -->
</web-app>
=========分界=========
把Test.class放在classes目录下
重新启动tomcat以后,http://localhost:8080/jsp/Test
提示:
type Status reportmessage /jsp/Testdescription The requested resource (/jsp/Test) is not available.
在webapps下自建jsp目录
jsp目录下有 WEB-INF ,同时编写了web.xml
可以访问jsp下的test.jsp现在弄了一个servlet
编译没有问题
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Test extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out=response.getWriter();
out.println("<html>;<body>;<h1>;This is a servlet test.</h1>;</body>;</html>;");
out.flush();
}
}
================分界线================
web.xml如下
<?xml version="1.0" encoding="ISO-8859-1"?>
<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>Test</servlet-name>
<servlet-class>Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/Test</url-pattern>
</servlet-mapping>
<!-- JSPC servlet mappings end -->
</web-app>
=========分界=========
把Test.class放在classes目录下
重新启动tomcat以后,http://localhost:8080/jsp/Test
提示:
type Status reportmessage /jsp/Testdescription The requested resource (/jsp/Test) is not available.
解决方案 »
- 急!java 如何解析两层中括号[[]] 的json格式文件.
- 学生信息管理
- java.lang.NoSuchMethodError?帮帮忙看看这是怎么回事?
- Tomcat配到eclipse中出了问题。各位大大帮忙看一下是哪里的错啊 附图片上来了 (前面发的那个图片看不到重新发一下)
- 在struts中应用ajax更新表单。
- struts2+Spring 中spring.xml配置问题请教!
- 编译java文件报错
- 小小的问题,搞定给分
- 一个关于用jbuilder开发jsp的问题
- 求解,网上查了半天了,jsp中import一个java类报错解决不了
- 弱弱的问你下,这样的java面试题目你会吗
- jstl中的表达式中含有函数如何处理?
在前面加上
package test;
重新编译,修改web.xml的<servlet-class>test.test</servlet-class>
然后修改了 web.xml 把
<servlet>
<servlet-name>Test</servlet-name>
<servlet-class>Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/Test</url-pattern>
</servlet-mapping>
加入
通过访问 http://localhost:8080/Test 可以正常访问!
不过我的 http://localhost:8080/jsp/test.jsp都是可以正常访问的
但是 http://localhost:8080/jsp/Test不可以修改web.xml都重新启动过tomcat
把root下的web-inf都拷贝到jsp目录下
就可以了