zoukankan      html  css  js  c++  java
  • javaWEB项目感受

    1.WEB-INF下的内容是受保护的,不能直接访问,可以通过转发的方式访问。

    2.OGNL技术: 

      对象图像导航语言,是一种功能强大的表达式语言。可以让我们用非常简单的表达式访问对象层。

      OGNL引擎访问对象的格式:Ognl.getValue("OGNL表达式",对象本身);

      OGNL表达式:可以包含任何,包括各类表达式,计算公式,对象属相。某些方法等

    步骤一:创建对象类,通过OGNL来取对应的数

    package org.tedu.action;
    
    import java.util.List;
    import java.util.Map;
    
    public class Foo {
    
        private Integer id;
        private String name;
        private String[] array;
        private List<String> list;
        private Map<String,String> map;
        
        public Integer getId() {
            return id;
        }
        public void setId(Integer id) {
            this.id = id;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public String[] getArray() {
            return array;
        }
        public void setArray(String[] array) {
            this.array = array;
        }
        public List<String> getList() {
            return list;
        }
        public void setList(List<String> list) {
            this.list = list;
        }
        public Map<String, String> getMap() {
            return map;
        }
        public void setMap(Map<String, String> map) {
            this.map = map;
        }
        
    }

    步骤二:具体去的方式

     1 package org.tedu.action;
     2 
     3 import java.util.ArrayList;
     4 import java.util.HashMap;
     5 import java.util.List;
     6 import java.util.Map;
     7 
     8 import ognl.Ognl;
     9 import ognl.OgnlException;
    10 
    11 public class TestOGNL {
    12 
    13     public static void main(String[] args) throws OgnlException {
    14         Foo f=new Foo();
    15         f.setId(1);
    16         f.setName("Bosh");
    17         f.setArray(new String[]{"one","two","three"});
    18         List<String> list=new ArrayList<String>();
    19         list.add("a");
    20         list.add("b");
    21         list.add("c");
    22         f.setList(list);
    23         
    24         Map<String,String> map=new HashMap<String,String>();
    25         map.put("1", "java");
    26         map.put("2", "hadoop");
    27         map.put("3", "python");
    28         f.setMap(map);
    29         
    30         System.out.println(Ognl.getValue("id", f));
    31         System.out.println(Ognl.getValue("id+78", f));
    32         System.out.println(Ognl.getValue("name", f));
    33         System.out.println(Ognl.getValue(""what is" + name", f));
    34         System.out.println(Ognl.getValue("array", f));
    35         System.out.println(Ognl.getValue("list", f));
    36         System.out.println(Ognl.getValue("map", f));
    37         System.out.println(Ognl.getValue("name.toUpperCase()", f));
    38     }
    39 }

    结果:

    1
    79
    Bosh
    what isBosh
    [Ljava.lang.String;@12b82368
    [a, b, c]
    {3=python, 2=hadoop, 1=java}
    BOSH

  • 相关阅读:
    Construct Binary Tree from Preorder and Inorder Traversal
    Construct Binary Tree from Inorder and Postorder Traversal
    Maximum Depth of Binary Tree
    Sharepoint 2013 创建TimeJob 自动发送邮件
    IE8 不能够在Sharepoint平台上在线打开Office文档解决方案
    TFS安装与管理
    局域网通过IP查看对方计算机名,通过计算机名查看对方IP以及查看在线所有电脑IP
    JS 隐藏Sharepoint中List Item View页面的某一个字段
    SharePoint Calculated Column Formulas & Functions
    JS 两个一组数组转二维数组
  • 原文地址:https://www.cnblogs.com/lwy19998273333/p/5490048.html
Copyright © 2011-2022 走看看