- 浏览: 232241 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (281)
- hibernate (16)
- sql工具 (2)
- eclipse (15)
- tomcat (13)
- 项目部署 (4)
- java (62)
- spring (15)
- EL (1)
- javascript (8)
- 正则表达式 (1)
- jQuery (4)
- mysql (15)
- jstl (1)
- jsp (1)
- eclipse,eclipse插件 (1)
- svn (4)
- java,resin (1)
- jdbc (1)
- jdk (2)
- android (21)
- resin (3)
- php (3)
- 其他 (2)
- 数据库 (2)
- cas单点登录 (2)
- 邮箱激活 (1)
- jad (1)
- 支付 (1)
- struts (1)
- jpa (1)
- struts2 (4)
- json (3)
- oracle (2)
- velocity (1)
- sina微博登陆 (2)
- qq账户登录 (1)
- spring security (1)
- java图片处理 (1)
- http请求 (1)
- cas springsecurity (1)
- freemarker (1)
- cas (6)
- java oauth2 (2)
- oauth2.0 (6)
- springsecurity oauth2 (1)
- sms (1)
- springmvc (2)
- spring aop (1)
- luaeclipse (1)
- cocos2d (1)
- hibernate缓存 (1)
- ibatis (1)
- linux (7)
- 技术网站 (1)
- python (2)
- hadoop (1)
- war3 (0)
- elasticsearch (2)
- jboss (1)
- spring data jpa (2)
- java json (1)
- jsonp (1)
- webservice (4)
- java多线程 (1)
- java加密解密 (1)
- spring task (1)
- java session and cookie (1)
- java nio (1)
- 缓存 (1)
- java大数据 (1)
- cygwin (1)
- 设计模式 (1)
- mybatis (2)
- jquery插件 (2)
- jvm内存溢出 (1)
- drools (1)
- cookie and session (1)
- jvm内存设置 (1)
- nginx (1)
- 微信 (1)
- extjs (1)
- redis (7)
- memcached (1)
- js闭包 (1)
- js (0)
- mongodb (3)
- dubbo (2)
- jdk版本问题 (1)
- opnfire (1)
- git (1)
- jsp视频播放 (1)
- 国际化 (1)
- 后台管理 (1)
- yum (1)
- k (1)
- 算法 (0)
- jvm优化 (1)
- java检测 (1)
- maven操作 (0)
- ios打包 (1)
- 网络通信 (1)
- node.js (1)
- maven (4)
- 消息队列 (2)
- springcloud (6)
- mq (2)
- idea (3)
- log4j (1)
- docker (4)
- editplus (1)
- springboot (1)
- Kubernetes (1)
- jenkins (1)
- websocket (1)
- thirft (1)
- strom (1)
- postman (1)
- kafka (1)
- 线程池 (1)
- JVisualVM (1)
- java反射 (1)
- shell (1)
- java8 (2)
- i18 (1)
- jvm (0)
- nio (1)
- nodejs (1)
- idea java (1)
最新评论
-
pengfeifei26:
wbzhaohl 写道这个有解决方案没有时间长了,貌似有点忘了 ...
A redirect is required to get the users approval -
wbzhaohl:
这个有解决方案没有
A redirect is required to get the users approval -
somebody:
恩。好吧。这个只有在 还没发布的 2.0 版本才有。
oauth2.0设置自动授权
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; public class SaxHandler extends DefaultHandler { /* 此方法有三个参数 arg0是传回来的字符数组,其包含元素内容 arg1和arg2分别是数组的开始位置和结束位置 */ @Override public void characters(char[] arg0, int arg1, int arg2) throws SAXException { String content = new String(arg0, arg1, arg2); System.out.println(content); super.characters(arg0, arg1, arg2); } @Override public void endDocument() throws SAXException { System.out.println("\n…………结束解析文档…………"); super.endDocument(); } /* arg0是名称空间 arg1是包含名称空间的标签,如果没有名称空间,则为空 arg2是不包含名称空间的标签 */ @Override public void endElement(String arg0, String arg1, String arg2) throws SAXException { System.out.println("结束解析元素 " + arg2); super.endElement(arg0, arg1, arg2); } @Override public void startDocument() throws SAXException { System.out.println("…………开始解析文档…………\n"); super.startDocument(); } /*arg0是名称空间 arg1是包含名称空间的标签,如果没有名称空间,则为空 arg2是不包含名称空间的标签 arg3很明显是属性的集合 */ @Override public void startElement(String arg0, String arg1, String arg2, Attributes arg3) throws SAXException { System.out.println("开始解析元素 " + arg2); if (arg3 != null) { for (int i = 0; i < arg3.getLength(); i++) { // getQName()是获取属性名称, System.out.print(arg3.getQName(i) + "=\"" + arg3.getValue(i) + "\""); } } System.out.print(arg2 + ":"); super.startElement(arg0, arg1, arg2, arg3); } } import java.util.ArrayList; import java.util.HashMap; import java.util.List; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; public class SaxHandler extends DefaultHandler { private HashMap<String, String> map = null; private List<HashMap<String, String>> list = null; /** * 正在解析的元素的标签 */ private String currentTag = null; /** * 正在解析的元素的值 */ private String currentValue = null; private String nodeName = null; public List<HashMap<String, String>> getList(){ return list; } public SaxHandler(String nodeName) { this.nodeName = nodeName; } @Override public void startDocument() throws SAXException { // TODO 当读到一个开始标签的时候,会触发这个方法 list = new ArrayList<HashMap<String,String>>(); } @Override public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { // TODO 当遇到文档的开头的时候,调用这个方法 if(name.equals(nodeName)){ map = new HashMap<String, String>(); } if(attributes != null && map != null){ for(int i = 0; i < attributes.getLength();i++){ map.put(attributes.getQName(i), attributes.getValue(i)); } } currentTag = name; } @Override public void characters(char[] ch, int start, int length) throws SAXException { // TODO 这个方法用来处理在XML文件中读到的内容 if(currentTag != null && map != null){ currentValue = new String(ch, start, length); if(currentValue != null && !currentValue.trim().equals("") && !currentValue.trim().equals("\n")){ map.put(currentTag, currentValue); } } currentTag=null; currentValue=null; } @Override public void endElement(String uri, String localName, String name) throws SAXException { // TODO 在遇到结束标签的时候,调用这个方法 if(name.equals(nodeName)){ list.add(map); map = null; } super.endElement(uri, localName, name); } }
发表评论
-
二叉树创建和遍历
2015-03-30 22:10 636package test; import java. ... -
solr使用
2015-03-08 12:31 0http://www.52menshao.com/conten ... -
关于算法
2014-03-31 18:48 354http://bbs.csdn.net/topics/3907 ... -
java js 插件
2014-03-27 16:08 311http://www.malot.fr/bootstrap-d ... -
关于java模式
2014-03-13 17:04 253http://gxl-ct001.iteye.com/blog ... -
关于秒杀
2014-02-25 18:47 0http://www.blogjava.net/dongbul ... -
json格式时间转java时间
2014-01-08 16:17 1001http://surongly.iteye.com/blog/ ... -
Java时间日期格式转换
2014-01-03 18:26 411http://blog.csdn.net/Miniyaner/ ... -
JAVA调用sms
2014-01-03 16:15 383http://sms.webchinese.cn/api.sh ... -
oauth2.0 accesstoken验证无效处理类
2013-12-24 19:20 1046org.springframework.security.oa ... -
oauth2.0设置自动授权
2013-12-24 19:12 1329将 oauth_client_details 库表中autoa ... -
刷新access_token 类
2013-12-24 18:52 602刷新access_token 类 先删除掉库里保存的记录,然 ... -
oauth2.0怎么验证accesstoken是否正确或合法
2013-12-24 18:05 2084验证access_token流程 OAuth2Authent ... -
怎么样判断accesstoken是否过期
2013-12-24 18:02 1764用code去换取token的时候,会返回三个参数:现在的acc ... -
Java模拟HTTP的Get和Post请求
2013-09-17 17:03 1048/** post * 调用httpClient ... -
通过url获取图片并保存至本地
2013-09-17 15:39 1140/** * 通过url获取图片并保存至本 ... -
css 控制字数,多出用...表示
2013-09-16 18:20 1189<html> <head> ... -
com/caucho/server/http/ResinServer
2013-09-12 18:33 1109java.lang.NoClassDefFoundError: ... -
sina微博和腾讯微博OAuth2.0授权笔记实例
2013-09-04 09:56 764sina微博和腾讯微博OAuth2.0授权笔记实例 -
sina微博oauth2 获取accessToken
2013-09-02 23:25 1016public String execute() throw ...
相关推荐
SAX解析XML文件的实例。一个项目同时用dom解析和sax解析xml文件貌似会报错,项目框架建一直是用sax和dom4j解析xml文件的。当我用dom解析xml文件。导入包后就报错识别不了xml文件的编码格式。于是做了一个sax解析xml...
Java SAX解析Xml Demo(详细注释)
JAVA SAX解析XMLJAVA SAX解析XMLJAVA SAX解析XML
使用java语言对XML文档进行解析的示例,包括DOM,SAX方式,并包括使用jdom和jom4j框架进行XML解析或生成XML文档
JAVA 解析XML和生成XML文档源码。比较全 1.DOM生成和解析XML文档 2.SAX生成和解析XML文档 3.DOM4J生成和解析XML文档 4.JDOM生成和解析XML
java学习笔记——使用DOM解析XML和使用SAX解析XML
java操作xml,包括dom、sax解析
java解析XML文件java解析XML文件java解析XML文件java解析XML文件java解析XML文件java解析XML文件
NULL 博文链接:https://lujo20121128.iteye.com/blog/1736765
java demo,采用sax解析xml
java 解析xml 方法 sax jdom dom stAX
Sax解析xml文件详细例子,解析复杂节点的xml,把内容显示到view中,例子简单完整,易用
1、java SAX方式的XML解析 和 Myeclipse工程源码 2、java 正则表达式详解和常用例子
java从服务器读取xml文件并以SAX方式解析附带(服务器与解析源码)
Java使用sax、dom、dom4j解析xml文档的代码,包含dom4j的jar包。
使用sax解析xml的源代码
NULL 博文链接:https://wang-peng1.iteye.com/blog/1133695
java读取RSS-SAX解析XML的实例,java语言编写,使用时只需要在main方法中将参数换成自己的RSS地址即可。
学习xml——sax解析的项目小示例 非常简单易懂 而且包括多种sax解析的方法 如xmlReader,saxBuilder工厂,还包括一个dom解析的示例(DocumentBuilder工厂)
Java 解析XML性能分析Demo。包含了DOM解析,SAX解析, JDOM解析,DOM4J解析,JAXB解析例子。