java web项目做的网上支付,jsp跳转到servlet时浏览器显示跳转到servlet,但是是一片空白,求大神指点
1,servlet程序中加几句system.out语句看看有没有输出,
成都创新互联专注于尉犁网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供尉犁营销型网站建设,尉犁网站制作、尉犁网页设计、尉犁网站官网定制、小程序定制开发服务,打造尉犁网络公司原创品牌,更为您提供尉犁网站排名全网营销落地服务。
2,用浏览器打开,然后打开开发者工具看看提示。有时候eclipse自带的web browse显示网页有问题,
java编写一个网上支付系统界面
html
head
meta http-equiv="Content-Type" content="text/html; charset=utf-8"
title购物与结算/title
style type="text/css"
/style
link rel="stylesheet" href="
script src="
script src="
script src="
script src="
(beta4)/IE9.js"/script
script src="
script type="text/javascript"
function pay()
{
var link = document.getElementById("a1");
link.click();
var a = new Array();
a[0]="html教程";
a[1]=12;
a[2]=1;
a[3]=a[1]*a[2];
var a1 = new Array();
a1[0]="java详解";
a1[1]=25;
a1[2]=2;
a1[3]=a1[1]*a1[2];
var b = new Array();
b[0]=a;
b[1]=a1;
var amount =0;
for(var i=0;ib.length;i++)
{
var c = new Array();
c=b[i];
amount = amount+c[3];
var tr ="tr";
for(var j=0;jc.length;j++)
{
tr+="td"+c[j]+"/td";
}
tr+="/tr";
$("#list").append(tr);
$("#all").html("b总计:/bfont color=\"red\""+amount+"/font")
}
}
function goon()
{
var link = document.getElementById("a2");
link.click();
$("#news").html("支付成功!!");
}
/script
/head
body
input type="button" class="btn btn-danger" value="点击结算" onclick="pay()"
a href="#myModaltishi" role="button" class="btn" data-toggle="modal" id="a1" style="display: none"/a
div id="myModaltishi" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
div class="modal-header"
button type="button" class="close" data-dismiss="modal" aria-hidden="true"×/button
h3 id="myModalLabel"购物车/h3
/div
div class="modal-body"
div
table id="list" style="width: 95%;" class="table"
th商品名称/th
th单价/th
th数量/th
th金额/th
/table
/div
div align="right" id="all"/div
/div
div class="modal-footer"
button class="btn" data-dismiss="modal" aria-hidden="true"继续挑选/button
button class="btn btn-primary" data-dismiss="modal" onclick="goon()"支付/button
/div
/div
a href="#myModaltishi1" role="button" class="btn" data-toggle="modal" id="a2" style="display: none"/a
div id="myModaltishi1" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
div class="modal-header"
button type="button" class="close" data-dismiss="modal" aria-hidden="true"×/button
h3 id="myModalLabel"系统提示/h3
/div
div class="modal-body"
h3 id="news" align="center"/h3
/div
div class="modal-footer"
button class="btn btn-primary" data-dismiss="modal"知道了/button
/div
/div
/body
!-- 浏览器打开可查看效果,
另外由于页面使用了bootstrap框架建议使用渲染较高的浏览器,例如:火狐 --
/html
怎么用java调用微信支付接口
java调用微信支付接口方法:
RequestHandler requestHandler = new RequestHandler(super.getRequest(),super.getResponse());
//获取token //两小时内有效,两小时后重新获取
Token = requestHandler.GetToken();
//更新token 到应用中
requestHandler.getTokenReal();
System.out.println("微信支付获取token=======================:" +Token);
//requestHandler 初始化
requestHandler.init();
requestHandler.init(appid,appsecret, appkey,partnerkey, key);
// --------------------------------本地系统生成订单-------------------------------------
// 设置package订单参数
SortedMapString, String packageParams = new TreeMapString, String();
packageParams.put("bank_type", "WX"); // 支付类型
packageParams.put("body", "xxxx"); // 商品描述
packageParams.put("fee_type", "1"); // 银行币种
packageParams.put("input_charset", "UTF-8"); // 字符集
packageParams.put("notify_url", ""); // 通知地址 这里的通知地址使用外网地址测试,注意80端口是否打开。
packageParams.put("out_trade_no", no); // 商户订单号
packageParams.put("partner", partenerid); // 设置商户号
packageParams.put("spbill_create_ip", super.getRequest().getRemoteHost()); // 订单生成的机器IP,指用户浏览器端IP
packageParams.put("total_fee", String.valueOf(rstotal)); // 商品总金额,以分为单位
// 设置支付参数
SortedMapString, String signParams = new TreeMapString, String();
signParams.put("appid", appid);
signParams.put("noncestr", noncestr);
signParams.put("traceid", PropertiesUtils.getOrderNO());
signParams.put("timestamp", timestamp);
signParams.put("package", packageValue);
signParams.put("appkey", this.appkey);
// 生成支付签名,要采用URLENCODER的原始值进行SHA1算法!
String sign ="";
try {
sign = Sha1Util.createSHA1Sign(signParams);
} catch (Exception e) {
e.printStackTrace();
}
// 增加非参与签名的额外参数
signParams.put("sign_method", "sha1");
signParams.put("app_signature", sign);
// api支付拼包结束------------------------------------
//获取prepayid
String prepayid = requestHandler.sendPrepay(signParams);
System.out.println("prepayid :" + prepayid);
// --------------------------------生成完成---------------------------------------------
//生成预付快订单完成,返回给android,ios 掉起微信所需要的参数。
SortedMapString, String payParams = new TreeMapString, String();
payParams.put("appid", appid);
payParams.put("noncestr", noncestr);
payParams.put("package", "Sign=WXPay");
payParams.put("partnerid", partenerid);
payParams.put("prepayid", prepayid);
payParams.put("appkey", this.appkey);
//这里除1000 是因为参数长度限制。
int time = (int) (System.currentTimeMillis() / 1000);
payParams.put("timestamp",String.valueOf(time));
System.out.println("timestamp:" + time);
//签名
String paysign ="";
try {
paysign = Sha1Util.createSHA1Sign(payParams);
} catch (Exception e) {
e.printStackTrace();
}
payParams.put("sign", paysign);
//拼json 数据返回给客户端
BasicDBObject backObject = new BasicDBObject();
backObject.put("appid", appid);
backObject.put("noncestr", payParams.get("noncestr"));
backObject.put("package", "Sign=WXPay");
backObject.put("partnerid", payParams.get("partnerid"));
backObject.put("prepayid", payParams.get("prepayid"));
backObject.put("appkey", this.appkey);
backObject.put("timestamp",payParams.get("timestamp"));
backObject.put("sign",payParams.get("sign"));
String backstr = dataObject.toString();
System.out.println("backstr:" + backstr);
return backstr;
====================到此为止,预付款订单已生成,并且已返回客户端====================
//坐等微信服务器通知,通知的地址就是生成预付款订单的notify_url
ResponseHandler resHandler = new ResponseHandler(request, response);
resHandler.setKey(partnerkey);
//创建请求对象
//RequestHandler queryReq = new RequestHandler(request, response);
//queryReq.init();
if (resHandler.isTenpaySign() == true) {
//商户订单号
String out_trade_no = resHandler.getParameter("out_trade_no");
System.out.println("out_trade_no:" + out_trade_no);
//财付通订单号
String transaction_id = resHandler.getParameter("transaction_id");
System.out.println("transaction_id:" + transaction_id);
//金额,以分为单位
String total_fee = resHandler.getParameter("total_fee");
//如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee
String discount = resHandler.getParameter("discount");
//支付结果
String trade_state = resHandler.getParameter("trade_state");
//判断签名及结果
if ("0".equals(trade_state)) {
//------------------------------
//即时到账处理业务开始
//------------------------------
System.out.println("----------------业务逻辑执行-----------------");
//——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
System.out.println("----------------业务逻辑执行完毕-----------------");
System.out.println("success"); // 请不要修改或删除
System.out.println("即时到账支付成功");
//给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知
resHandler.sendToCFT("success");
//给微信服务器返回success 否则30分钟通知8次
return "success";
}else{
System.out.println("通知签名验证失败");
resHandler.sendToCFT("fail");
response.setCharacterEncoding("utf-8");
}
}else {
System.out.println("fail -Md5 failed");
用Java怎么实现微信支付?
具体方法步骤:
一、准备阶段:已认证微信号,且通过微信支付认证,这个可以看微信文档,很详细,这里就不再重复。
二、配置授权目录,官方推荐使用https类型的url,不知道http能不能行,个人也推荐使用https的保证不会错。
配置授权域名
三、微信支付二次开发所需要的参数:
APP_ID,APP_KEY,PARTNER,PARTNER_KEY(AppSecret)
APP_ID和PARTNER_KEY(AppSecret)
PARTNER
APP_KEY(自行设置32位字符)
四、具体编程
1、通过页面跳转到确认支付页面,其中的redirect_uri必须是配置授权目录下的。
2、获取到openid,再经服务器向微信请求获取prepay_id,封装字段并进行签名后通过jsapi调起微信支付
3、测试结果
能不能也给我一段JAVA在线支付的代码?
import com.capinfo.crypt.*;
public class RsaTest
{
public RsaTest(){
}
public static void main(String[] args){
//首信公钥文件
String publicKey = "d:/Public1024.key";
//签名信息
String SignString = "3e5671bc4f91c3d055b18c1e5e22dd9db157380c7ee8facf0b1117082fbf398d7113c2df7e3219fc28dd88dd26cb096cabe607f3e397dfc2dcdb3349351a5f025ea0761da6e39e2d2fd311294a6076e777fe2ab8911f22113c435b89d63ae4f2aff2f333f7ebd40cc89601d58fb37b16596b5c94eb8b64cd52e12b9679248e6a";
//原信息
String strSource = "abcde12345";
try{
//公钥验证
RSA_MD5 rsaMD5 = new RSA_MD5();
int k = rsaMD5.PublicVerifyMD5(publicKey,SignString,strSource);
if(k==0)
System.out.println("验证成功.");
else
System.out.println("验证失败.");
}catch(Exception e){
System.out.println("验证异常.\n"+e);
}
}
}
用java编程实现网上超市购物结算功能代码
哎,我还是自己代码黏贴给你吧!免得总通不过!装不下这么多字,详情自己找我。 连接数据库类(添加修改会员信息) package com.to.java; import java.util.Scanner; import java.sql.*; public class Vds { Scanner Input=new Scanner(System.in); ZhuCK1 zhuck1=new ZhuCK1(); public void x(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); System.out.println("----------查询结果---------"); System.out.println(); System.out.println("会员号--密码"); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } con.close(); stmt.close(); }catch(Exception e){ System.out.println(e);} System.out.println("是否返回上级菜单"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("欢迎下次再次使用");System.exit(-1);}; break; }} public void j(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } Scanner input=new Scanner(System.in); System.out.println("请输入会员信息:"); System.out.println("请输入会员号:"); String f=input.next(); System.out.println("请输入密码:"); String q=input.next(); String sqlst="insert into gg values('"+f+"','"+q+"')"; Statement tatement=con.createStatement(); int result=tatement.executeUpdate(sqlst); System.out.println("操作成功!"); con.close(); stmt.close(); }catch(Exception e){ System.out.println(e); } System.out.println("是否返回上级菜单"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("欢迎下次再次使用");System.exit(-1);}; break; } } public void xg(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } Scanner input=new Scanner(System.in); System.out.println("请输入会员信息:"); System.out.println("请输入要修改的会员号:"); String f=input.next(); System.out.println("请输入修改的密码:"); String q=input.next(); String sqlst="update gg set mm='"+q+"' where id='"+f+"'"; Statement tatement=con.createStatement(); int result=tatement.executeUpdate(sqlst); System.out.println("操作成功!"); con.close(); stmt.close(); }catch(Exception e){ System.out.println(e); } System.out.println("是否返回上级菜单"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("欢迎下次再次使用");System.exit(-1);}; break; } } } package com.to.java; import java.util.Scanner; public class KeHu { Vds sj=new Vds(); public void kehu1(){ Scanner Input=new Scanner(System.in); ZhuCK1 zhuck1=new ZhuCK1(); System.out.println("******************************************************"+"\n\n"); System.out.println("1.显示所有客户信息"); System.out.println("2.添加客户信息"); System.out.println("3.修改客户信息"); System.out.println("4.查询客户信息"); System.out.println("5.返回上级菜单"); System.out.println("******************************************************"+"\n\n"); System.out.println("请输入数字:"); int a=Input.nextInt(); switch(a){ case 1: sj.x(); break; case 2: sj.j(); break; case 3: sj.xg(); break; case 4: sj.x();break; case 5: zhuck1.ZhucK1();break; } } } package com.to.java; public class GouWuXiTong { public static void main(String[] args){ ZhuCK zhuck=new ZhuCK(); zhuck.ZhucK(); } } package com.to.java; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.Scanner; public class ZhuCK { Scanner Input=new Scanner(System.in); public void ZhucK(){ ZhuCK1 zhuck1=new ZhuCK1(); System.out.println("\t\t"+"欢迎使用我心我素购物系统"); System.out.println("******************************************************"+"\n\n"); System.out.println("\t\t"+"1.登陆系统"); System.out.println(); System.out.println("\t\t"+"2.退出"+"\n\n"); System.out.println("******************************************************"); int d=1; while(d!=2){ System.out.println("请输入会员号:"); String p=Input.next(); System.out.println("请输入密码:"); String f=Input.next(); try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select * from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); if(id.equals(p)mm.equals(f)){ { System.out.println("请输入数字:"); int a=Input.nextInt(); switch(a){ case 1: zhuck1.ZhucK1(); break; case 2: break; }d=2; } } } }catch(Exception e){ System.out.println(e);} {System.out.println("输入错误请再次输入:");d=1;} } }} }
网页题目:java网上支付代码 java实现支付
本文路径:http://lswzjz.com/article/hhcdid.html