java创建Xml笔记
用java创建Xml的4大类:
Element:节点类
Attribute属性类
Document:指的就是文档类
XMLOutput:输出类
此类是用java建立一个xml文件
public class TestJdom {
//创建XML(模型)dom
public static void main(String[] args) {
createXmlDom();
}
public static void createXmlDom(){
Element beans=new Element("beans");
Element bean=new Element("bean");
Attribute id=new Attribute("id","dataSource");
Attribute clazz=new Attribute("class","org.apache.commons.dbcp.BasicDataSource");
bean.setAttribute(id);
bean.setAttribute(clazz);
beans.addContent(bean);
Map map=new HashMap();
map.put("driverClassName", "com.mysql.jdbc.Driver");
map.put("username", "root");
map.put("password", "root");
map.put("url", "jdbc:mysql://localhost:3306/test");
for(Map.Entry mapEntry:map.entrySet()){
Element property=new Element("property");
property.setAttribute("name", mapEntry.getKey());
Element value=new Element("value");
value.setText(mapEntry.getValue());
&nb
相关文档:
别的都不说了,我的感觉是学习到了一种框架的思想:就是开发一个基础框架,然后这个框架再别的地方一样可以使用!
比较重要的知识点:
1: HTTP 协议解析,
2:封装response 、request
3:给系统定制日志组件
4:给系统添加配置文件,增加了系统的灵活性和耦合性.这里主要是用的一个开源项目(据说Tomcat就是用的这个开� ......