read-JpetStore-3-用户管理

    JPetStore用户管理分析

JPetStore将登陆后的用户ActionForm保持于Session作用域中,在页面中判断该ActionForm中的用户信息,实现了简单的用户验证。

 

Ø 进入用户管理

 <a href="<c:url value="/shop/signonForm.do"/>">

 

Ø Struts-config.xml配置

<action path="/shop/signonForm"

    type="org.springframework.samples.jpetstore.web.struts.DoNothingAction"

                validate="false">

            <forward name="success" path="/WEB-INF/jsp/struts/SignonForm.jsp"/>

    </action>

 

Ø 进入用户登陆的SignonForm.jsp

<form action="<c:url value="/shop/signon.do"/>" method="POST">

<c:if test="${!empty signonForwardAction}">

<input type="hidden" name="forwardAction"

value="<c:url value="${signonForwardAction}"/>"/>

</c:if>

<td colspan="2">Please enter your username and password.

<td><input type="text" name="username" value="j2ee" /></td>

<td><input type="password" name="password" value="j2ee" /></td>

<td><input type="image" border="0" src="../images/button_submit.gif" name="update"

<a href="<c:url value="/shop/newAccountForm.do"/>">

<img border="0" src="../images/button_register_now.gif" />

</a>

</form>

Ø SignonAction

i)              <action path="/shop/signon"

        type="org.springframework.samples.jpetstore.web.struts.SignonAction"

                name="accountForm" scope="session" validate="false">

            <forward name="success" path="/shop/index.do"/>

         </action>

ii)           <form-bean name="accountForm"

type="org.springframework.samples.jpetstore.web.struts.AccountActionForm"/>

 

iii)        SignonAction

public class SignonAction extends BaseAction {

  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

    request.getSession().removeAttribute("workingAccountForm");

    request.getSession().removeAttribute("accountForm");

    //如果用户注销,则清空Session

    if (request.getParameter("signoff") != null) {

      request.getSession().invalidate();

      return mapping.findForward("success");

    }

        else {

      AccountActionForm acctForm = (AccountActionForm) form;

      String username = acctForm.getUsername();

      String password = acctForm.getPassword();

      //用户验证

      Account account = getPetStore().getAccount(username, password);

      if (account == null) {

        request.setAttribute("message", "Invalid username or password.  Signon failed.");

        return mapping.findForward("failure");

      }

            else {

                String forwardAction = acctForm.getForwardAction();

                acctForm = new AccountActionForm();

                acctForm.setForwardAction(forwardAction);

        acctForm.setAccount(account);

        acctForm.getAccount().setPassword(null);

        PagedListHolder myList = new PagedListHolder(getPetStore().getProductListByCategory(account.getFavouriteCategoryId()));

                myList.setPageSize(4);

                acctForm.setMyList(myList);

    //用户通过验证后,将ActiongFrom存入Session

                request.getSession().setAttribute("accountForm", acctForm);

        if (acctForm.getForwardAction() == null || acctForm.getForwardAction().length() < 1) {

          return mapping.findForward("success");

        }

                else {

          response.sendRedirect(acctForm.getForwardAction());

          return null;

        }

      }

    }

  }

}

 

iv)          

 

 

<!查找Session中是否存在accountForm.account对象,以此判断用户是否登陆-->

    <c:if test="${!empty accountForm.account}">

    <b><i><font size="2" color="BLACK">Welcome

    <!如果已经登陆,显示欢迎信息-->

<c:out value="${accountForm.account.firstName}"/>!</font></i></b>

    </c:if>

    <!查找Session中是否存在accountForm.account对象,以此判断用户是否登陆-->

<c:if test="${!empty accountForm.account}" >

    <!如果已经登陆,显示修改用户信息URL-->

      <a href="<c:url value="/shop/signon.do?signoff=true"/>">

<img border="0" name="img_signout" src="../images/sign-out.gif" /></a>

         <img border="0" src="../images/separator.gif" />

      <a href="<c:url value="/shop/editAccountForm.do"/>">

<img border="0" name="img_myaccount" src="../images/my_account.gif" /></a>

</c:if>

v)             

 

        <action path="/shop/editAccountForm" type="org.springframework.samples.jpetstore.web.struts.EditAccountFormAction"

                name="workingAccountForm" scope="session"  validate="false">

<forward name="success" path="/WEB-INF/jsp/struts/EditAccountForm.jsp"/>

    </action>

<form-bean name="workingAccountForm" type="org.springframework.samples.jpetstore.web.struts.AccountActionForm"/>

 

大概看了看,总的来说,JPetStore的应用逻辑还是比较简单,JpetStore的学习和分析也就到此结束。

标题中提及的“BOE-B2-154-240-JD9851-Gamma2.2_190903.rar”标识了一款由京东方公司生产的液晶显示单元,属于B2产品线,物理规格为154毫米乘以240毫米,适配于JD9851型号设备,并采用Gamma2.2标准进行色彩校正,文档生成日期为2019年9月3日。该压缩文件内包含的代码资源主要涉及液晶模块的底层控制程序,采用C/C++语言编写,用于管理显示屏的基础运行功能。 液晶模块驱动作为嵌入式系统的核心软件组成部分,承担着直接操控显示硬件的任务,其关键作用在于通过寄存器读写机制来调整屏幕的各项视觉参数,包括亮度、对比度及色彩表现,同时负责屏幕的启动与关闭流程。在C/C++环境下开发此类驱动需掌握若干关键技术要素: 首先,硬件寄存器的访问依赖于输入输出操作,常借助内存映射技术实现,例如在Linux平台使用`mmap()`函数将寄存器地址映射至用户内存空间,进而通过指针进行直接操控。 其次,驱动需处理可能产生的中断信号,如帧缓冲区更新完成事件,因此需注册相应的中断服务例程以实时响应硬件事件。 第三,为确保多线程或进程环境下共享资源(如寄存器)的安全访问,必须引入互斥锁、信号量等同步机制来避免数据竞争。 第四,在基于设备树的嵌入式Linux系统中,驱动需依据设备树节点中定义的硬件配置信息完成初始化与参数设置。 第五,帧缓冲区的管理至关重要,驱动需维护该内存区域,保证图像数据准确写入并及时刷新至显示面板。 第六,为优化能耗,驱动应集成电源管理功能,通过寄存器控制实现屏幕的休眠与唤醒状态切换。 第七,针对不同显示设备支持的色彩格式差异,驱动可能需执行色彩空间转换运算以适配目标设备的色彩输出要求。 第八,驱动开发需熟悉液晶显示控制器与主处理器间的通信接口协议,如SPI、I2C或LVDS等串行或并行传输标准。 最后,完成代码编写后需进行系统化验证,包括基础显示功能测试、性能评估及异常处理能力检验,确保驱动稳定可靠。 该源代码集合为深入理解液晶显示控制原理及底层驱动开发实践提供了重要参考,通过剖析代码结构可掌握硬件驱动设计的具体方法与技术细节。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值