- 浏览: 100517 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (209)
- http://docs.jpush.io/server/java_sdk/ (1)
- SpingMVC ModelAndView (1)
- Model (1)
- Control以及参数传递 (1)
- https://www.alipay.com/ (1)
- 检查指定的字符串列表是否不为空。 (1)
- 转自http://my.oschina.net/rpgmakervx/blog/505434 (1)
- 压缩js (1)
- 含包含 字母数字校验 (1)
- 判断浏览器是ie (1)
- fixbox (0)
- 转自http://www.cnblogs.com/lanzi/archive/2010/10/26/1861338.html (1)
- http://dl2.iteye.com/upload/attachment/0113/2406/afbd8d53-dcad-3afc-8d78-41c1591 (0)
- IDEA (0)
- maven搭建 (0)
- http://www.jeasyuicn.com/api/docTtml/index.htm (1)
- 给tomcat添加运行内存: (1)
- JPUSH推送 (1)
- requestScope (0)
- oracle中plsql安装client10连接数据库 (1)
- 不需要安装oracle11g (1)
- tuikuan (1)
- http://www.hjxmall.com/index.php (1)
- java (1)
- 参考 (1)
- xml签名验签模拟程序 (1)
- 技术网站收集分享 (1)
- Java NIO提供了与标准IO不同的IO工作方式 ------来源于 http://www.iteye.com/magazines/132-Java-NIO (1)
- oracle表查询语句优化 (0)
- oracle (5)
- a (1)
- TenpayHttpClient (2)
- mongodb (1)
- http://www.qcloud.com/product/cmongo.html?utm_source=pcsem1&utm_medium=bdgj46&utm_campaign=baidu (1)
- SpringMVC整合MongoDB开发 (0)
- SpringMVC整合MongoDB开发 https://www.mongodb.org (1)
- Java 语言中常见问题总结 (1)
- 数据库SQL优化大总结 (1)
- 拦截器与过滤器的区别 (1)
- Struts2中拦截器与过滤器的区别及执行顺序 (1)
- Spring声明式事务管理与配置 (0)
- oracle OPERTION (1)
- java 高并发多线程开发 (1)
- Collection 与 map 接口相关集合 (1)
- 多线程开发实践 (1)
- JVM调优总结 转自 http://www.importnew.com/18694.html (1)
- redis 五种数据类型的使用场景 转自于 http://blog.csdn.net/gaogaoshan/article/details/41039581 (1)
- HttpWatch http基础 来自于http://blog.csdn.net/gaogaoshan/article/details/21237555 (1)
- maven 远程仓库 http://blog.csdn.net/gaogaoshan/article/details/40266779 (1)
- 生成Webservice客户端的4中方法 http://blog.csdn.net/gaogaoshan/article/details/8980775 (1)
- http://fgh2011.iteye.com/blog/1564283 (1)
- sleep和wait有什么区别 http://xiaowei2002.iteye.com/blog/2174188 (1)
- JDK中常用包及其类 常见的几种RuntimeException (1)
- Java的运行原理 (1)
- mybatis缓存的使用及理解 http://my.oschina.net/dxqr/blog/123163 (1)
- 软件架构设计分析 (1)
- redis技术总结 (3)
- java面试总结知识点 (1)
- ZooKeeper技术 (1)
- Hadoop (1)
- sso单点登录 (1)
- SpringIOC (1)
- 书签ssssssssssssssssssssss (1)
- spring事务的隔离级别 http://www.cnblogs.com/yangy608/archive/2011/06/29/2093478.html (1)
- 秒杀系统架构分析与实战 http://www.importnew.com/18920.html (1)
- oracle 连接plsql配置 (1)
- maven工程集成springmvc http://blog.csdn.net/fox_lht/article/details/16952683 (1)
- java类序列化与反序列化版本唯一号serialVersionUID (1)
- spring注解用法总结 (1)
- eclipse导入maven项目找不到资源文件方法 (1)
- dubbo (0)
- socket 网络编程 服务器与客户端 编程 (1)
- Thread与Runnable实现线程利用线程插队实现求和操作 (1)
- 生产者与消费者模式 (1)
- JAXB注解 java 关于xml的注解,自动生成xml文件 - @XML*** (1)
- xml 与JAVAbean转换 (1)
- MAP (2)
- decimalToString (1)
- 反编译插件 (0)
- 反编译插件 https://sourceforge.net/projects/jadclipse/?source=typ_redirect (1)
- AWX (1)
- 官网地址Dinp (1)
- public interface ExecutorService extends Executor (1)
- MAIN (1)
- 转自于 http://blog.csdn.net/lufeng20/article/details/24314381 (1)
- JaxbUtil (1)
- HttpXmlClient (0)
- Http post 请求 (1)
- URLDecoder (1)
- spdb (0)
- 订单号生成规则 (1)
- 距离0点毫秒数 (1)
- MyBatis存储过程调用java (1)
- Banks (1)
- 学习网址 (1)
- hots配置oracle数据库配置修改 (1)
- 支付宝文档 (1)
- Jadclipse (1)
- filter (0)
- Filter过滤器 (1)
- 工具类 fixbox (1)
- java quartz (0)
- java quartz 实现定时任务,每个礼拜一到礼拜五定时执行 (1)
- Thread (4)
- getResourceAsStream (1)
- BigData (1)
- 开源架构 (17)
- 架构 (0)
- 文件操作 (2)
- tools (20)
- 测试工具 (1)
- vm (1)
- mq (1)
- blog (1)
- 开源架构搭建技术 (6)
- JAVA细节技术点总结 (1)
- 优化技术 (1)
- LINUX命令使用 (1)
- spring (2)
- 大数据 (1)
- struts2 (1)
- python (1)
- pay (1)
- linux (1)
- 压力测试 (1)
- 代码检查插件 (1)
- 游戏端开发 (1)
- 微信开发相关 (1)
- 搜索引擎 (1)
- 网络技术 (1)
- 分布式部署 (1)
- 堆栈信息 (1)
最新评论
/**
* 解析返回的xml格式字符串中是否包含指定的元素
* 包含则返回值,否则返回空字符串
* @param result
* @param element
* @return
*/
@SuppressWarnings("deprecation")
public static String getValue(String result, String element) {
String str = "";
if (StringUtils.isNotEmpty(result) && StringUtils.isNotEmpty(element) && result.contains(element)) {
try {
int elementIndex = result.indexOf(element);
int middleIndex = result.indexOf("&");
if (elementIndex > middleIndex) {
str = result.substring(elementIndex + element.length() + 1, result.length());
} else {
str = result.substring(elementIndex + element.length() + 1, middleIndex);
}
return java.net.URLDecoder.decode(str);
} catch (Exception e) {
log.info("解析数据时未找到相关元素:" + element);
}
}
return str;
}
public static void main(String[] args) {
String str = "Plain=TranAbbr%3DIPER%7CAcqSsn%3D000012307996%7CMercDtTm%3D20160620143930%7CTermSsn%3D12434509%7CRespCode%3D00%7CTermCode%3D00000000%7CMercCode%3D983708160001401%7CTranAmt%3D0.01%7CSettDate%3D20160620&Signature=a12132qq";
String str1 = getValue(str, "Plain");
System.out.println("Plain ===" + str1);
String str2 = getValue(str, "Signature");
System.out.println("Signature ===" + str2);
String str3 = getElementValue(str,"Plain");
System.out.println("Plain = " + str3);
String str4 = getElementValue(str,"Signature");
System.out.println("Signature = " + str4);
}
@SuppressWarnings("deprecation")
private static String getElementValue(String str, String string) {
Map<String,String> map = new HashMap<String, String>();
if (StringUtils.isNotEmpty(str) && StringUtils.isNotEmpty(string) && StringUtils.contains(str, string)) {
String [] inputStr = StringUtils.split(str,"&");
for(int i = 0; i< inputStr.length; i++){
String key = inputStr[i].split("=")[0];
String value = inputStr[i].split("=")[1];
map.put(key, value);
}
}
return map.size() > 0 ? java.net.URLDecoder.decode(map.get(string)) : "";
}
@SuppressWarnings("deprecation")
private static Map<String, String> getElementToMap(String str) {
Map<String, String> map = new HashMap<String, String>();
if (StringUtils.isNotEmpty(str) && str.contains("&")) {
String[] inputArr = StringUtils.split(str, "&");
for (int i = 0; i < inputArr.length; i++) {
String key = inputArr[i].split("=")[0];
String value = inputArr[i].split("=")[1];
map.put(key, value);
}
}
return map.size() > 0 ? map : new HashMap<String, String>();
}
public static String sendMessage(String message) throws IOException {
// 对报文进行URLENcoder编码
message = URLEncoder.encode(message,"utf-8");
OutputStreamWriter osw = null;
HttpURLConnection httpConn = null;
BufferedReader br = null;
StringBuilder buff = new StringBuilder();
try {
URL url = new URL(BankMessageUtil.ChinapayMobilePayUrl);
httpConn = (HttpURLConnection) url.openConnection();
httpConn.setDoOutput(true);
httpConn.setRequestMethod("POST");
httpConn.setRequestProperty("Content-length", "" + message.getBytes().length);
httpConn.setRequestProperty("Content-Type", "application/octet-stream");
httpConn.setRequestProperty("Charset", "utf-8");
httpConn.setConnectTimeout(10000);
httpConn.setReadTimeout(30000);
// 写入信息
osw = new OutputStreamWriter(httpConn.getOutputStream());
osw.write(message);
osw.flush();
// 读取返回结果
String line = null;
br = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
while((line = br.readLine()) != null) {
buff.append(line);
}
} catch(Exception e) {
log.error("ChinaPayMobileUtil exception", e);
} finally {
if (osw != null) {
osw.close();
}
if (br != null) {
br.close();
}
}
// URLDecoder解码
String result = URLDecoder.decode(buff.toString(), "utf-8").replaceAll("\r|\n|\t", "");
return result;
}
* 解析返回的xml格式字符串中是否包含指定的元素
* 包含则返回值,否则返回空字符串
* @param result
* @param element
* @return
*/
@SuppressWarnings("deprecation")
public static String getValue(String result, String element) {
String str = "";
if (StringUtils.isNotEmpty(result) && StringUtils.isNotEmpty(element) && result.contains(element)) {
try {
int elementIndex = result.indexOf(element);
int middleIndex = result.indexOf("&");
if (elementIndex > middleIndex) {
str = result.substring(elementIndex + element.length() + 1, result.length());
} else {
str = result.substring(elementIndex + element.length() + 1, middleIndex);
}
return java.net.URLDecoder.decode(str);
} catch (Exception e) {
log.info("解析数据时未找到相关元素:" + element);
}
}
return str;
}
public static void main(String[] args) {
String str = "Plain=TranAbbr%3DIPER%7CAcqSsn%3D000012307996%7CMercDtTm%3D20160620143930%7CTermSsn%3D12434509%7CRespCode%3D00%7CTermCode%3D00000000%7CMercCode%3D983708160001401%7CTranAmt%3D0.01%7CSettDate%3D20160620&Signature=a12132qq";
String str1 = getValue(str, "Plain");
System.out.println("Plain ===" + str1);
String str2 = getValue(str, "Signature");
System.out.println("Signature ===" + str2);
String str3 = getElementValue(str,"Plain");
System.out.println("Plain = " + str3);
String str4 = getElementValue(str,"Signature");
System.out.println("Signature = " + str4);
}
@SuppressWarnings("deprecation")
private static String getElementValue(String str, String string) {
Map<String,String> map = new HashMap<String, String>();
if (StringUtils.isNotEmpty(str) && StringUtils.isNotEmpty(string) && StringUtils.contains(str, string)) {
String [] inputStr = StringUtils.split(str,"&");
for(int i = 0; i< inputStr.length; i++){
String key = inputStr[i].split("=")[0];
String value = inputStr[i].split("=")[1];
map.put(key, value);
}
}
return map.size() > 0 ? java.net.URLDecoder.decode(map.get(string)) : "";
}
@SuppressWarnings("deprecation")
private static Map<String, String> getElementToMap(String str) {
Map<String, String> map = new HashMap<String, String>();
if (StringUtils.isNotEmpty(str) && str.contains("&")) {
String[] inputArr = StringUtils.split(str, "&");
for (int i = 0; i < inputArr.length; i++) {
String key = inputArr[i].split("=")[0];
String value = inputArr[i].split("=")[1];
map.put(key, value);
}
}
return map.size() > 0 ? map : new HashMap<String, String>();
}
public static String sendMessage(String message) throws IOException {
// 对报文进行URLENcoder编码
message = URLEncoder.encode(message,"utf-8");
OutputStreamWriter osw = null;
HttpURLConnection httpConn = null;
BufferedReader br = null;
StringBuilder buff = new StringBuilder();
try {
URL url = new URL(BankMessageUtil.ChinapayMobilePayUrl);
httpConn = (HttpURLConnection) url.openConnection();
httpConn.setDoOutput(true);
httpConn.setRequestMethod("POST");
httpConn.setRequestProperty("Content-length", "" + message.getBytes().length);
httpConn.setRequestProperty("Content-Type", "application/octet-stream");
httpConn.setRequestProperty("Charset", "utf-8");
httpConn.setConnectTimeout(10000);
httpConn.setReadTimeout(30000);
// 写入信息
osw = new OutputStreamWriter(httpConn.getOutputStream());
osw.write(message);
osw.flush();
// 读取返回结果
String line = null;
br = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
while((line = br.readLine()) != null) {
buff.append(line);
}
} catch(Exception e) {
log.error("ChinaPayMobileUtil exception", e);
} finally {
if (osw != null) {
osw.close();
}
if (br != null) {
br.close();
}
}
// URLDecoder解码
String result = URLDecoder.decode(buff.toString(), "utf-8").replaceAll("\r|\n|\t", "");
return result;
}
相关推荐
在这个封装接口中,`LoadConfigFile`和`SaveConfigFile`负责XML文件的读写,`GetElementValue`和`SetElementValue`用于获取或设置元素的值,`AddElement`和`RemoveElement`则提供了添加和删除元素的功能。...
4. `GetElementValue(string elementPath)`:根据XPath表达式获取元素的值。 5. `SetElementValue(string elementPath, string newValue)`:通过XPath更新元素的值。 6. `RemoveElement(string elementPath)`:删除...
GetElementValue()和SetElementValue()用于获取或设置元素的值。 5. **属性操作**:使用GetAttribute()和GetAttributeIndex()可以获取元素的属性及其索引,而HasAttribute()检查元素是否包含指定属性。SetAttribute...
5. **获取元素值**:`GetElementValue(string xpath)`方法通过XPath表达式查找元素并返回其文本值。这使得读取XML文件中的特定信息变得简单。 6. **设置元素值**:`SetElementValue(string xpath, string value)`...
function getElementValue(element) { return element.getAttribute("value"); } ``` 这样可以在不同浏览器下统一获取元素的值。 #### 总结 以上介绍了在开发跨浏览器兼容的网页应用时可能会遇到的一些常见问题...
public final String getElementValue(Node elem) { Node child; if (elem != null && elem.hasChildNodes()) { for (child = elem.getFirstChild(); child != null; child = child.getNextSibling()) { if ...