编写过程中需要注意的问题:
1.建立eclipse动态web工程时,需要改写编译后class文件的位置,通常情况下是这个位置:/WebContent/WEB-INF/classes
2.配置的页面链接和servlet类之间有两种方式:
1)通过在web.xml文件中进行配置:示例如下
jspshow1
listTheStudent
com.guodiantong.javaweb.ListTheStudent
listTheStudent
/list
deleteTheStudent
com.guodiantong.javaweb.DeleteServlet
deleteTheStudent
/delete
2)通过在eclipse新建servlet时,自动指示设置页面请求和servlet类之间的链接关系:如下图所示
new--->servlet
这种也能实现请求和对应的servlet类之间的映射,通过这种方式你会发下,tomcat使用的注解的方式@WebServlet,这种方式在web.xml文件中并没有通过 1)的那种方式显现出来
谈完上述注意的地方,下面开始见工程:先看下项目的目录结构
先看下所有的jsp文件:test.jsp文件
pageEncoding="ISO-8859-1"%>
Insert title herestudents.jsp文件:
pageEncoding="UTF-8"%>
Insert title hereList stus=(List)request.getAttribute("students");
%>
flowid | type | id_card | exam_card | studentname | location | grade | 操作 |
---|
for(Student student:stus){
%>
删除}
%>
success.jsp文件:
pageEncoding="UTF-8"%>
Insert title here操作成功!&#