zoukankan      html  css  js  c++  java
  • jsp自定义标签

    1.controller中查出数据
    Map<String, Object> custom = customersController.basic(custId);
    model.put("customer", custom);

    2.JSP中接收code值调用自定义标签
    <div class="profile-info-name"> 居住城市:</div>
        <div class="profile-info-value">
            <span>${fns:getCity(customer.lifeCode)}</span>
        </div>

    3.fns.tld自定义标签
    <?xml version="1.0" encoding="UTF-8" ?>
    <taglib xmlns="http://java.sun.com/xml/ns/j2ee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
            version="2.0">
        <function>
            <description>根据城市编码获取城市</description>
            <name>getCity</name>
            <function-class>com.loan.admin.web.utils.RestApiUtil</function-class>
            <function-signature>java.lang.String getCity(java.lang.String)</function-signature>
            <example>${fns:getCity(object)}</example>
        </function>
    </taglib>

    4.调用【com.loan.admin.web.utils.RestApiUtil】下getCity方法
        public static String getCity(String code){
            try {
                String name = "";
                String cityName = "";
                List<String> list = new ArrayList();
                Map<String, Object> params = Maps.newLinkedHashMap();
                while(!"0".equals(code)&&!"".equals(code)&&code!=null){
                    params.put("code", code);
                    String resp = RestApiUtil.doPost("loan/user/findChinaRegion/", params);
                    JSONObject jsonObject = JSONObject.parseObject(resp);
                    if(null!=jsonObject.get("result")&&!"".equals(jsonObject.get("result"))){
                        code = jsonObject.getJSONObject("result").getString("parentCode");
                        name = jsonObject.getJSONObject("result").getString("name");
                        list.add(name);
                    }else{
                        break;
                    }
                }
                for(int i=0;i<list.size();i++){
                    cityName = list.get(i).toString() + cityName;
                }
                return  cityName;
            }catch (Exception e){
                return "";
            }
        }

  • 相关阅读:
    解决:Requested 'libdrm_radeon >= 2.4.56' but version of libdrm_radeon is 2.4.52
    解决Ubuntun 12.04编译Mesa10.3 WARNING: 'aclocal-1.14' is missing on your system
    交叉编译Mesa,X11lib,Qt opengl
    Qt5.4.1移植到arm——Linuxfb篇
    Qt5.3.0的安装与测试
    gstreamer——文档/资源/使用
    gst-rtsp-server编译测试
    gstreamer-tips-picture-in-picture-compositing
    Matlab实现加性高斯白噪声信道(AWGN)下的digital调制格式识别分类
    Matlab实现单(双)极性(不)归零码
  • 原文地址:https://www.cnblogs.com/anjunshuang/p/9293991.html
Copyright © 2011-2022 走看看