zoukankan      html  css  js  c++  java
  • JavaWeb_(Struts2框架)Servlet与Struts区别

      JavaWeb_(SSH)使用Servlet实现用户的登陆  传送门

      JavaWeb_(SSH)使用Struts框架实现用户的登陆  传送门

      MySQL数据库中存在Gary用户,密码为123;第一次登陆时输入错误的密码1234后页面重定向,并输出错误的提示信息第二次登陆时输入正确的密码,页面跳转到index.jsp中

     启动:
      servlet  无
      struts  配置filter
     
     
    创建
      servlet  继承HttpServlet,实现doget,dopost,
            添加注解,或者配置web.xml
      struts   继承ActionSupport,写一个带有String返回值且抛出一个异常的函数
            配置struts.xml
     
     
    封装参数
      servlet  导入包BeanUtils,根据name属性自动封装
      struts  实现ModelDriven接口,实现getModel方法
     
     
    转发与重定向
      servlet
        转发:request.getRequestDispatcher("/login.jsp").forward(request, response);;
        重定向:response.sendRedirect(request.getContextPath()+"/index.html");
     
      struts
        转发
          package
            action
              result默认为转发,
        重定向
          package
            aciton
              result中type="redirect"
    (如需转载学习,请标明出处)
  • 相关阅读:
    JS的type类型为 text/template
    Vue之x-template(2)
    Vue之x-template(1)
    vue之$mount
    console.log()与console.dir()
    Less用法注意事项
    一次 Linux 系统被攻击的分析过程
    WebAR 如何改变增强现实的未来
    开发中的测试名词解释
    Flutter 同步系统的 HTTP 代理设置
  • 原文地址:https://www.cnblogs.com/1138720556Gary/p/10478820.html
Copyright © 2011-2022 走看看