举例:
import java.io.File
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
import org.w3c.dom.Document
import org.w3c.dom.Element
import org.w3c.dom.NodeList
public class DomTest1
{
public static void main(String[] args) throws Exception
{
// step 1: 获得dom解析器工厂(工作的作用是用于创建具体的解析器)
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance()
// System.out.println("class name: " + dbf.getClass().getName())
// step 2:获得具体的dom解析器
DocumentBuilder db = dbf.newDocumentBuilder()
// System.out.println("class name: " + db.getClass().getName())
// step3: 解析一个xml文档,获得Document对象(根结点)
Document document = db.parse(new File("candidate.xml"))
NodeList list = document.getElementsByTagName("PERSON")
for(int i = 0i <list.getLength()i++)
{
Element element = (Element)list.item(i)
String content = element.getElementsByTagName("NAME").item(0).getFirstChild().getNodeValue()
System.out.println("name:" + content)
System.out.println("--------------------------------------")
}
}
}
1.准备数据:在excel中构造出需要的数据3.将新保存到文本文件中的数据导入到pl*sql中
在pl*sql中选择tools--text importer,在出现的窗口中选择Data from Textfile,然后再选择Open data file,
在d出的文件选择框中选中保存有数据的文本文件,此时将会看到data from textfile中显示将要导入的数据!
spring链接配置即可。
一、<dependencyManagement>
<dependencies>
<!-- 使用spring的BOM管理依赖 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.2.6.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
二、<!-- spring配置开始 --><dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- spring配置结束 -->
三、在web工程的src/main/resources/META-INF目录下添加dispatcher.xml文件,并添加如下配置:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)