上次的问题我了解一点了,但是还不能解决,请求帮助
文件布局是这样的%tomcat_home%\kjgl\WEB-INF\classes
%tomcat_home%\kjgl 下面统一放的是JSP文件 如:login.jsp(登陆界面) getstudent.jsp(学生信息)
%tomcat_home%\kjgl\WEB-INF\classes 下面统一放.class文件 如:login_confirm.class
%tomcat_home%\kjgl\WEB-INF 下面放的是web.xml
问题来了
地址栏输入: http://127.0.0.1:9000/kjgl/login.jsp
正常显示登陆画面,输入信息正确,login.jsp 通过语句 action="/kjgl/login_confirm"连接到login_confirm.class,地址栏显示http://127.0.0.1:9000/kjgl/login_confirm
之后出现问题了
login_confirm.class 通过语句 if(kind.equals("student")) {
RequestDispatcher rd = getServletContext().getRequestDispatcher("/student.jsp");
本应该要连接到 getstudent.jsp ,地址栏显示 http://127.0.0.1:9000/kjgl/getStudent.jsp
貌似路径正确,因为存在 C:\Tomcat\webapps\kjgl\getStudent.jsp
但是显示 无法正常显示 或者 显示 wrong name:kjgl\sqlBean (sqlBean是class文件,在其它.class中引用到
是不是应该在web.xml中添加什么?
上面情况下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>Tomcat Documentation</display-name>
<description>
<!--
<description>oralceDB</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/orcldb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>-->
</description>
<servlet>
<servlet-name>login_confirm</servlet-name>
<servlet-class>login_confirm</servlet-class>
</servlet>
<servlet-mapping>
<url-pattern>/login_confirm</url-pattern>
<servlet-name>login_confirm</servlet-name>
</servlet-mapping>
<servlet>
<servlet-name>StudentSvlt</servlet-name>
<servlet-class>StudentSvlt</servlet-class>
</servlet>
<servlet-mapping>
<url-pattern>/StudentSvlt</url-pattern>
<servlet-name>StudentSvlt</servlet-name>
</servlet-mapping>
<servlet>
<servlet-name>TeacherSvlt</servlet-name>
<servlet-class>TeacherSvlt</servlet-class>
</servlet>
<servlet-mapping>
<url-pattern>/TeacherSvlt</url-pattern>
<servlet-name>TeacherSvlt</servlet-name>
</servlet-mapping>
<servlet>
<servlet-name>CourseSvlt</servlet-name>
<servlet-class>CourseSvlt</servlet-class>
</servlet>
<servlet-mapping>
<url-pattern>/CourseSvlt</url-pattern>
<servlet-name>CourseSvlt</servlet-name>
</servlet-mapping>
<servlet>
<servlet-name>ClassSvlt</servlet-name>
<servlet-class>ClassSvlt</servlet-class>
</servlet>
<servlet-mapping>
<url-pattern>/ClassSvlt</url-pattern>
<servlet-name>ClassSvlt</servlet-name>
</servlet-mapping>
<servlet>
<servlet-name>StudentLoginSvlt</servlet-name>
<servlet-class>StudentLoginSvlt</servlet-class>
</servlet>
<servlet-mapping>
<url-pattern>/StudentLoginSvlt</url-pattern>
<servlet-name>StudentLoginSvlt</servlet-name>
</servlet-mapping>
<servlet>
<servlet-name>MarkSvlt</servlet-name>
<servlet-class>MarkSvlt</servlet-class>
</servlet>
<servlet-mapping>
<url-pattern>/MarkSvlt</url-pattern>
<servlet-name>MarkSvlt</servlet-name>
</servlet-mapping>
</web-app>
后面我胡乱加入代码
<servlet>
<servlet-name>webdav</servlet-name>
<servlet-class>org.apache.catalina.servlets.WebdavServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
和
<servlet>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<servlet-class>org.apache.jsp.index_jsp</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<url-pattern>/index.jsp</url-pattern>
</servlet-mapping>
还有
<servlet-mapping>
<servlet-name>webdav</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file/>
</welcome-file-list>
之后,http://127.0.0.1:9000/kjgl/getStudent.jsp页面显示出来了,但是,本来应该显示学生资料的,但是似乎没有连接上数据库
这到底是为什么呢?恳请高手们教我该如何修改此程序!