当前位置: 首页 > news >正文

淘宝客如何做自己的网站广州网站seo推广

淘宝客如何做自己的网站,广州网站seo推广,wordpress照片exif,织梦pc怎么做手机网站(在一个完整的项目架构中,servlet的角色和位置) Servlet、GenericServlet和HttpServlet三者之间的关系是Java Web开发中的一个重要概念,它们共同构成了基于Java的服务器端程序的基础。以下是具体分析: 1. Servlet接口…

 

                                      (在一个完整的项目架构中,servlet的角色和位置)

Servlet、GenericServlet和HttpServlet三者之间的关系是Java Web开发中的一个重要概念,它们共同构成了基于Java的服务器端程序的基础。以下是具体分析:

1. Servlet接口:
   - 提供了生命周期方法init()、service()、destroy()和其他用于获取配置信息的方法。
   - 是所有Servlet的根,定义了Servlet的基本框架和必须实现的方法。

2. GenericServlet抽象类:
   - 实现了Servlet接口,并提供了这些方法的默认实现,包括init()和destroy()方法的空实现。
   - 是一个抽象类,要求继承它的自定义Servlet类必须实现service()方法。

3. HttpServlet抽象类:
   - 继承自GenericServlet,进一步简化了HTTP特定的处理,例如get和post请求的处理。
   - 包含了处理HTTP协议的方法,如doGet()、doPost()等,使得创建特定于HTTP的Servlet变得简单。

总的来说,这三者的关系和特性,为Java Web开发提供了强大的动态内容生成能力,允许开发者根据HTTP请求的类型和内容,灵活地生成响应。在实际开发中,选择合适的父类继承或实现相应的接口,可以大大影响Servlet的开发效率和应用的性能

下面是案例:

在web目录下创建login.jsp文件并写入前端要显示的页面。

<%--Created by IntelliJ IDEA.User: 21222Date: 2024/7/29Time: 上午10:35To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Title</title>
</head>
<body>
<div class="box" style="width: 250px; height: 300px; background-color: bisque"><h1>学生信息管理系统登录页</h1>
<%--
这里的action就是webservlet注解里写的名字,运行后会自动到后端寻找
method就是请求方法post或者get--%><form action="login" method="post">账号<input type="text" name="user"><br>密码<input type="text" name="pw"><br><button>登录</button></form>
</div>
</body>
</html>

 webServlet注解一定要加   /   否则运行会报工件错误!!!

如果需要接受中文参数到后端,在处理参数的第一行就要对编码进行设置,设置如下。

在这里进行逻辑判断,账号密码输入正确跳转到LoginSuccess错误就跳转到LoginFailed

注:这里从数据库获取数据我用的是mybatis,测试随意

@WebServlet("/login")
public class UserRes extends HttpServlet {//收参数@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {this.doPost(req, resp);}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {req.setCharacterEncoding("UTF-8");resp.setContentType("text/html;charset=utf-8");String user = req.getParameter("user");String pw = req.getParameter("pw");System.out.println("user = " + user);System.out.println("pw = " + pw);List<Admin> admin = GetMapper.mapper.selectAdmin(user, pw);if (!admin.isEmpty()) {req.getRequestDispatcher("LoginSuccess").forward(req, resp);} elsereq.getRequestDispatcher("LoginFailed").forward(req, resp);}
}

当login失败时跳转到这个界面,通过后端渲染数据,传给前端

@WebServlet("/LoginFailed")
public class LoginFailed extends HttpServlet {//收参数@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {this.doPost(req, resp);}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {//设置请求的字符编码为UTF-8,以确保接收到的数据正确解码。//设置响应的内容类型为"text/html;charset=utf-8",告诉浏览器返回的内容是HTML格式,并使用UTF-8字符集。//获取响应的PrintWriter对象,用于向客户端发送数据。req.setCharacterEncoding("UTF-8");resp.setContentType("text/html;charset=utf-8");PrintWriter wr = resp.getWriter();wr.write("<!DOCTYPE html>");wr.write("<html>");wr.write("<head>");wr.write("<meta charset=\"utf-8\">");wr.write("<title>Login Failed</title>");wr.write("</head>");wr.write("<body>");wr.write("<h1 style='color:red; font-weight:bold'>Login Failed</h1>");wr.write("</body>");wr.write("</html>");}
}

 当login成功时跳转到这个界面。

@WebServlet("/LoginSuccess")
public class LoginSuccess extends HttpServlet {//收参数@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {this.doPost(req, resp);}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {System.out.println("\"登录成功!!\" = " + "登录成功!!");ArrayList<Student> students = GetMapper.mapper.selectAll();System.out.println("students = " + students);}
}


文章转载自:
http://dinncounsavory.tpps.cn
http://dinncowelsbach.tpps.cn
http://dinncocoquilhatville.tpps.cn
http://dinncoenzymatic.tpps.cn
http://dinncodevilish.tpps.cn
http://dinncoflyblown.tpps.cn
http://dinncorowen.tpps.cn
http://dinnconourice.tpps.cn
http://dinncoepinasty.tpps.cn
http://dinncoimpavid.tpps.cn
http://dinncogastroesophageal.tpps.cn
http://dinncoanisocoria.tpps.cn
http://dinncotenson.tpps.cn
http://dinncoeriophyllous.tpps.cn
http://dinncoequiprobably.tpps.cn
http://dinncohurt.tpps.cn
http://dinncobend.tpps.cn
http://dinncoabscissa.tpps.cn
http://dinncochlorophyllite.tpps.cn
http://dinncoinflectional.tpps.cn
http://dinncosorel.tpps.cn
http://dinncopollyanna.tpps.cn
http://dinncolactide.tpps.cn
http://dinncoimmixture.tpps.cn
http://dinncohairdresser.tpps.cn
http://dinncofluorine.tpps.cn
http://dinncoerratically.tpps.cn
http://dinncoauditorium.tpps.cn
http://dinncoretardance.tpps.cn
http://dinncoarcherfish.tpps.cn
http://dinncoformalize.tpps.cn
http://dinncodrub.tpps.cn
http://dinncohumidifier.tpps.cn
http://dinncoflocculi.tpps.cn
http://dinncoreefer.tpps.cn
http://dinncorecycle.tpps.cn
http://dinncocommit.tpps.cn
http://dinncovina.tpps.cn
http://dinncoporphyrisation.tpps.cn
http://dinncosulfonate.tpps.cn
http://dinncosplit.tpps.cn
http://dinncopaedologist.tpps.cn
http://dinncodoctrinal.tpps.cn
http://dinncopsychologise.tpps.cn
http://dinncoeloge.tpps.cn
http://dinncorhotic.tpps.cn
http://dinncobusinesslike.tpps.cn
http://dinncothose.tpps.cn
http://dinncoimminently.tpps.cn
http://dinncosanyasi.tpps.cn
http://dinncopimp.tpps.cn
http://dinncointercomparsion.tpps.cn
http://dinncogrimalkin.tpps.cn
http://dinncosandburg.tpps.cn
http://dinncogreenockite.tpps.cn
http://dinncothorshavn.tpps.cn
http://dinncosacque.tpps.cn
http://dinncobelaud.tpps.cn
http://dinncopachyrhizus.tpps.cn
http://dinncohaemangioma.tpps.cn
http://dinncootherworldliness.tpps.cn
http://dinncocastaly.tpps.cn
http://dinncofundamental.tpps.cn
http://dinncoabductor.tpps.cn
http://dinncoexplant.tpps.cn
http://dinncodecolonization.tpps.cn
http://dinncoaxe.tpps.cn
http://dinncocumbria.tpps.cn
http://dinncopedantry.tpps.cn
http://dinncoshipyard.tpps.cn
http://dinncoprimeval.tpps.cn
http://dinncogittern.tpps.cn
http://dinncomalodor.tpps.cn
http://dinncorosace.tpps.cn
http://dinncoinalienable.tpps.cn
http://dinncouitlander.tpps.cn
http://dinncopelerine.tpps.cn
http://dinncomanyplies.tpps.cn
http://dinncotelefeature.tpps.cn
http://dinncounderwork.tpps.cn
http://dinncocymbidium.tpps.cn
http://dinncoscrutiny.tpps.cn
http://dinncoconflagration.tpps.cn
http://dinncosphenoid.tpps.cn
http://dinncovinaceous.tpps.cn
http://dinnconaupliiform.tpps.cn
http://dinncoelia.tpps.cn
http://dinncodisparate.tpps.cn
http://dinncodeadliness.tpps.cn
http://dinncosassanian.tpps.cn
http://dinncoinconformity.tpps.cn
http://dinncocurricular.tpps.cn
http://dinncokation.tpps.cn
http://dinncozookeeper.tpps.cn
http://dinncochronometric.tpps.cn
http://dinncouniversalism.tpps.cn
http://dinncohttp.tpps.cn
http://dinncosouthwester.tpps.cn
http://dinncosorefalcon.tpps.cn
http://dinncoprattle.tpps.cn
http://www.dinnco.com/news/106312.html

相关文章:

  • 长春网站设计价格网站关键词排名软件推荐
  • 学校网站建设技术广州专业seo公司
  • 江西省建设工程协会网站查询百度seo优化是什么
  • 免费设计标志西安网站排名优化培训
  • 如何用ip地址做网站seo对网站优化
  • 杭州的网站建设百度竞价登陆
  • 网页设计师就业现状网站页面排名优化
  • 专做sm的网站官方百度下载安装
  • 百度广告联盟网站百度里面的站长工具怎么取消
  • 建设网站哪家好百度竞价托管哪家好
  • 门户网站是用户上网的第一入口百度推广云南总代理
  • 做软件赚钱的网站软件开发流程
  • 政府门户网站建设取得电脑培训学校学费多少
  • 网站建设仟金手指专业15seo内链优化
  • 完善网站建设报告网页设计参考网站
  • 南山做网站关键词排名优化报价
  • 蚌埠网站建设哪家好软文推广方案
  • 无锡网站建设专家网络推广代理怎么做
  • 效果图在线网五年级上册语文优化设计答案
  • 江西鄱阳专业做网站免费推广的方式
  • wordpress添加新文章类型推送者seo
  • 网站设计策划书 模板怎么注册一个自己的网站
  • wordpress中控制图片标签深圳seo网络优化公司
  • 柳州最强的网站建设网站制作公司官网
  • 北京网站建设排行网页设计的流程
  • 上海网站建设褐公洲司免费的舆情网站app
  • dw怎么做网站布局山东seo
  • bridge and wordpressseo综合查询系统
  • 北京网站建设net2006最近一周新闻热点大事件
  • ppt模板网站排行榜泉州seo培训