当前位置:网站首页>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 .
边栏推荐
- How to add a map to the legendary server
- 深度学习刷SOTA的一堆trick
- SparkSql批量插入或更新,保存数据到Mysql中
- Cache penetration, cache breakdown, cache avalanche and Solutions
- [sudden] solve remote: support for password authentication was removed on August 13, 2021. please use a perso
- JS daily question (11)
- AttributeError: ‘module‘ object has no attribute ‘create_connection‘
- Word如何查看文档修改痕迹?Word查看文档修改痕迹的方法
- office2010每次打开都要配置进度怎么解决?
- JDBC statement + resultset introduction
猜你喜欢

Activity workflow table structure learning

Mapper agent development

WPS insert hyperlink cannot be opened. What should I do if I prompt "unable to open the specified file"!

AUTOSAR from introduction to proficiency 100 lectures (78) -autosar-dem module

Glory 2023 push, push code ambubk

Jackson解析JSON详细教程

学习数据库的第一个程序

The song of the virtual idol was originally generated in this way!
![[untitled]](/img/04/242e85ee8eea5bd6ae8144fc048241.png)
[untitled]
Let you understand several common traffic exposure schemes in kubernetes cluster
随机推荐
sql日志
What if the computer cannot open excel? The solution of Excel not opening
Google GTEST event mechanism
Apache POI实现Excel导入读取数据和写入数据并导出
输入的查询SQL语句,是如何执行的?
Deep learning brush a bunch of tricks of SOTA
AUTOSAR从入门到精通100讲(七十八)-AUTOSAR-DEM模块
Use openmap and ArcGIS to draw maps and transportation networks of any region, and convert OMS data into SHP format
力扣------对奇偶下标分别排序
The method and detailed code of automatically pop-up and QQ group when players visit the website
Let you understand several common traffic exposure schemes in kubernetes cluster
浅谈AspectJ框架
荣耀2023内推,内推码ambubk
Create a mindscore environment in modelars, install mindvision, and conduct in-depth learning and training (Huawei)
深度学习刷SOTA的一堆trick
虚拟偶像的歌声原来是这样生成的!
Solve the warning prompt of MySQL mapping file
Jackson parsing JSON detailed tutorial
Climbing the pit of traffic flow prediction (III): using pytorch to realize LSTM to predict traffic flow
How is the entered query SQL statement executed?