当前位置:网站首页>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 .
边栏推荐
- Mapper agent development
- The representation of time series analysis: is the era of learning coming?
- AUTOSAR从入门到精通100讲(七十八)-AUTOSAR-DEM模块
- How to monitor micro web services
- Diagram of odoo development tutorial
- Wps如何使用智能填充快速填充数据?Wps快速填充数据的方法
- Network Security Learning - Intranet Security 1
- 网安学习-内网安全1
- Vivo market API event reporting and docking
- Mysql语句中的函数
猜你喜欢

How to make the characters in the photos laugh? HMS core video editing service one click smile function makes people smile more naturally

How to monitor micro web services

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

Introduction of JDBC preparestatement+ database connection pool

How does WPS take quick screenshots? WPS quick screenshot method

【2022新生学习】第三周要点

如何安装office2010安装包?office2010安装包安装到电脑上的方法

网安学习-内网安全1

< El table column> place multiple pictures
![[wechat applet -- solve the alignment problem of the last line of display:flex. (discontinuous arrangement will be divided into two sides)]](/img/ee/b424d876c64dac652d76f9f26e4b20.png)
[wechat applet -- solve the alignment problem of the last line of display:flex. (discontinuous arrangement will be divided into two sides)]
随机推荐
A little knowledge about management
What if the computer cannot open excel? The solution of Excel not opening
2021-11-02
关于servlet中实现网站的页面跳转
How does word view document modification traces? How word views document modification traces
Solution | get the relevant information about the current employees' highest salary in each department |
【无标题】
WPS如何进行快速截屏?WPS快速截屏的方法
优炫数据库启动失败,报网络错误
怎样监测微型的网站服务
搭建手机APP需要用到什么服务器
DataSourceClosedException: dataSource already closed at Mon Oct 25 16:55:48 CST 2021
P5714 [deep foundation 3. Case 7] obesity
Climbing the pit of traffic flow prediction (III): using pytorch to realize LSTM to predict traffic flow
Reply from the Secretary of jindawei: the company is optimistic about the market prospect of NMN products and has launched a series of products
【微信小程序--解决display:flex最后一行对齐问题。(不连续排列会分到两边)】
Double type nullpointexception in Flink flow calculation
使用Jstack、Jconsole和jvisualvm进行死锁分析
How to add a map to the legendary server
Vivo market API event reporting and docking