• 几种标签库中的一些特有使用


    一、Struts1.x

    1.<html:link action="/action">不用关心Web应用程序的路径和ActionServlet的映射关系。

    可以自动附加sessionid参数进行url重写。

    可以对参数信息进行url编码。

    备注:<c:url>标准标签也有<html:link>标签的后两个功能。

      <%
       Date now=new Date();
       request.setAttribute("now",now);
       request.setAttribute("name","天地玄");
       Map<String,String> map=new HashMap<String,String>();
       map.put("x","1");
       map.put("y","2");
       map.put("z","3");
       request.setAttribute("person",map);
       %>
        <a href="/strutsdemo/RegUser.do">注册(太差)</a><br>
        <a href="${pageContext.request.contextPath}/RegUser.do">注册(一般)</a><br>
        <html:link action="/RegUserUI">注册(很好)</html:link><br>
        <html:link action="/RegUserUI" paramId="username" paramName="name">注册(url编码)</html:link><br>
        <html:link action="/RegUserUI" paramId="t" paramName="now" paramProperty="time">注册(url编码)</html:link><br>
        <html:link action="/RegUserUI" name="person">注册(多个参数)</html:link><br>

    2.depts=coporation.getDepartments();

    request.setAttribute('corp',coporation);

    Department.getId()/getName()

    <html:optionsCollection name="corp" porperty="departments"   value="id" label="name"/>

    3.<html:form>
    ①.<html:form>标签的action属性的设置值是否以/开头、是否以.do结尾都是可以的。
    ②.使用<html:text>和<html:password>等标签可以回显数据。
    ③.设置<html:password>的value属性,让密码信息不要回显。
    ④.生成html文档的<form>标签,其focus属性还可以生成相应的javaScript代码。
    ⑤.获取action属性中路径所对应的scope域中的formbean,存在则获取,不存在则创建新的,再把这个formbean以一个特殊关键字保存在request中,以便其中的<html:xxx>标签获取值时使用。
    ⑥.通过想取消保存在Session中的FormBean中的复选框的勾选操作,引入reset方法。

       <html:form action="/RegUser" focus="password2">
        用户名:<html:text property="user.username"></html:text>
        <html:errors property="username"/><br>
        密码:<html:password property="user.password" value=""></html:password><br>
        确认密码:<html:password property="password2" value=""></html:password>
        <html:errors property="password2"/><br>
        身高:<html:text property="user.height"/><br>
       <html:submit titleKey="info.title"><bean:message key='info.submit' bundle='App'/></html:submit>
       <html:checkbox property="autoLogon"></html:checkbox>两星期自动登录
        </html:form>   
        <!-- 输出错误信息2 -->
        <hr><html:errors/><hr>

  • 相关阅读:
    win10自带邮箱应用无法查看qq邮箱应用解决办法
    Ubuntu紫色背景颜色代码
    VMware中对Linux虚拟机的网络配置静态IP的配置
    CentOS 7在VMware 12中共享文件看不见的问题?
    C++中让人忽视的左值和右值
    C++ allocator类学习理解
    C++11新特性 -----> 右值引用 &&
    重新认识new
    关于C++中nothrow的某某某
    stopPropagation, preventDefault 和 return false 的区别
  • 原文地址:https://www.cnblogs.com/mingforyou/p/2275302.html
Copyright © 2020-2023  润新知