当前位置:网站首页>About realizing page Jump of website in Servlet
About realizing page Jump of website in Servlet
2022-07-29 05:11:00 【jakeonil】
Front end typesetting is ugly , Please forgive me , Mainly to realize the function , If there is a problem , Please give me some advice .
First we need to prepare two html Page file of

The content displayed is
index.html:

findone.html The content of is :

What we need is to jump from the main page to the query page , Click the query button to complete the page Jump .
Click the back button to return to the main interface
Here we need two servlet Class to complete the corresponding operation
They are query classes :
package Servlet;
import Dao.MakerMemberImpl.MakerImpl;
import Dao.Makerservier;
import MakerMember.Maker;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class Servletfind extends ViewBaseServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int flag=0;
request.setCharacterEncoding("UTF-8");
String idfirst = request.getParameter("id");
int id=101;
try {
id = Integer.parseInt(idfirst);
} catch (Exception e){
flag=1;
}
if(flag!=1)
try {
Makerservier makerservier= null;
try {
makerservier = new MakerImpl();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Maker maker= makerservier.findmaker(id);
List<Maker> makerList=new ArrayList<Maker>();
makerList.add(maker);
HttpSession session=request.getSession();
session.setAttribute("makerList",makerList);
super.processTemplate("findone",request,response);
} catch (SQLException throwables) {
throwables.printStackTrace();
}
else{
response.sendRedirect("index");
}
}
}
And return classes :
package Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class Servletreturn extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.sendRedirect("index");// Redirect
}
}
And one of me web.xml The document of is :
<servlet>
<servlet-name>Servlet6</servlet-name>
<servlet-class>Servlet.Servletfind</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet6</servlet-name>
<url-pattern> /findone</url-pattern><!-- What should be filled in here is form The request sent by the form action The name of -->
</servlet-mapping>
<servlet>
<servlet-name>Servlet7</servlet-name>
<servlet-class>Servlet.Servletreturn</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet7</servlet-name>
<url-pattern> /return</url-pattern><!-- What should be filled in here is form The request sent by the form action The name of -->
</servlet-mapping>And my front-end html The content is :
main interface :
<div id="div_find">
<form action="find" method="post">
<h class="b4"> Query member information </h><br/>
Of the query Id: <input type="text" name="id"/><br/>
<input class="a2" type="submit" value=" check Inquiry "/>
</form>
</div>Query result interface :
<form id="form_find" action="return" method="post">
<input type="submit" value=" return " class="a2">
</form>In this way, you can complete the jump between the two interfaces , The principle of redirection is applied , One web Resource received client A After the request ,B Will inform A The client accesses another web resources C, This process is called redirection .
边栏推荐
- 输入的查询SQL语句,是如何执行的?
- Simple user-defined authentication interface rules
- Stack and queue and priority queue (large heap and small heap) simulation implementation and explanation of imitation function
- Improve the readability of your regular expressions a hundred times
- Mysql的自连接和联合查询
- IDEA中使用注解Test
- 网安学习-内网安全1
- Lenovo Savior r7000+ add ssd+ copy and partition the information of the original D disk to the new SSD
- Introduction of JDBC preparestatement+ database connection pool
- 1 sentence of code, get asp Net core binds multiple sources to the same class
猜你喜欢

ODOO开发教程之透视表

The method and detailed code of automatically pop-up and QQ group when players visit the website

Diagram of odoo development tutorial

开源汇智创未来 | 2022开放原子全球开源峰会 openEuler 分论坛圆满召开

How to set row height and column width in excel? The method of setting row height and column width in Excel

SM整合原来这么简单,步骤清晰(详细)

【微信小程序--解决display:flex最后一行对齐问题。(不连续排列会分到两边)】

Excel卡住了没保存怎么办?Excel还没保存但是卡住了的解决方法

js(forEach)出现return无法结束函数的解决方法

Traffic flow prediction pit climbing record (I): traffic flow data set, original data
随机推荐
AttributeError: ‘module‘ object has no attribute ‘create_connection‘
向往的开源之多YOUNG新生 | 从开源到就业的避坑指南来啦!
带你搞懂 Kubernetes 集群中几种常见的流量暴露方案
ODOO开发教程之图表
后置通知的流程分析与功能实现有哪些内容你还记得吗?
Original code, inverse code, complement code
Huawei ilearning AI mathematics foundation course notes
Flink+iceberg environment construction and production problem handling
P1009 [noip1998 popularization group] sum of factorials
力扣------对奇偶下标分别排序
How is the entered query SQL statement executed?
Open source Huizhi creates the future | the openeuler sub forum of 2022 open atom global open source summit was successfully held
The song of the virtual idol was originally generated in this way!
缓存穿透、缓存击穿、缓存雪崩以及解决方法
MySQL time calculation function
如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
On prepayment of house purchase
Learn the first program of database
基于注解的三层项目的改造及添加包扫描的方式
虚拟偶像的歌声原来是这样生成的!