重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

小程序商城java代码,小程序商城源代码免费下载

初学者java小程序,求java大神帮我补充一下空缺代码!

import java.util.Arrays;

施秉ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!

public class Array2 {

public static void main(String[] args) {

//声明一个名为myArray的数组,该数组有2行,每行列数不等,并为其分配内存空间

int[][] myArray = new int[2][];

myArray[0] = new int[5]; //第一行有5个元素,并为其分配内存空间

myArray[1] = new int[10]; //第二行有10个元素,并为其分配内存空间

for (int j = 0; j myArray[0].length; j++)

//用1-10之间的随机整数给第一行元素赋值

myArray[0][j] = (int)(Math.random() * 10);

//用100-200之间的随机整数给第二行元素赋值

for (int j=0; j myArray[1].length; j++)

myArray[1][j]=(int)(Math.random() * 100 + 100);

for (int i=0; i myArray.length; i++){ //输出myArray数组各元素的值

for (int j=0; j myArray[i].length; j++){

System.out.print(myArray[i][j]+" ");

}

System.out.println();

}

Arrays.sort(myArray[0]); //对第一行元素排序

Arrays.sort(myArray[1]); //对第二行元素排序

System.out.println("\n排序后的数组元素: ");

for (int i=0; imyArray.length;i++){ //再次输出myArray数组各元素的值

for (int j=0; jmyArray[i].length;j++){

System.out.print(myArray[i][j]+" ");

}

System.out.println();

}

}

}

7 3 9 6 7

103 165 166 148 103 179 128 109 120 156

排序后的数组元素:

3 6 7 7 9

103 103 109 120 128 148 156 165 166 179

微信小程序商城,前端PHP后端java,怎么部署呢?

打开项目根目录文件夹下。执行 mvn eclipse:eclipse命令,会生成项目结构,然后在eclipse导入就可以,不过有缘分的是我们用到了一个项目,哈哈,望给个最佳奥,可以一起探讨

小程序后台获取openId解密的java代码怎么写

一、获取code

将code作为参数传递过来

//如果有code,说明是微信小程序,根据code获取openId

//classify用于标识是哪个小程序

if (!CheckUtil.checkNulls( keUser.getCode(),keUser.getClassify())){

//

String openid = OpenIdUtil.oauth2GetOpenid(keUser.getCode(),keUser.getClassify());

printParamsLog(openid, logger);

keUser.setUserId(openid);

}1234567812345678

二、工具类

package com.util;

import net.sf.json.JSONObject;

import org.apache.http.client.HttpClient;

import org.apache.http.client.ResponseHandler;

import org.apache.http.client.methods.HttpGet;

import org.apache.http.impl.client.BasicResponseHandler;

import org.apache.http.impl.client.DefaultHttpClient;

import java.util.HashMap;

import java.util.Map;

/**

* @author xsx

*/

public class OpenIdUtil {

public static String oauth2GetOpenid(String code,String classify) {

String appid="";

String appsecret="";

switch (classify){

case "1":

//自己的配置appid

appid = "**********";

//自己的配置APPSECRET;

appsecret = "**********";

break;

case "2":

appid = "**********";

appsecret = "************";

break;

case "3":

appid = "**********";

appsecret = "************";

break;

case "4":

appid = "**********";

appsecret = "************";

break;

case "5":

appid = "**********";

appsecret = "************";

}

//授权(必填)

String grant_type = "authorization_code";

//URL

String requestUrl = "";

//请求参数

String params = "appid=" + appid + "secret=" + appsecret + "js_code=" + code + "grant_type=" + grant_type;

//发送请求

String data = HttpUtil.get(requestUrl, params);

//解析相应内容(转换成json对象)

JSONObject json = JSONObject.fromObject(data);

//用户的唯一标识(openid)

String Openid =String.valueOf(json.get("openid"));

//System.out.println(Openid);

return Openid;

}

}

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960

三、发送请求的工具类

package com.util;

import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.net.URL;

import java.net.URLConnection;

import java.util.List;

import java.util.Map;

/**

* @author xsx

*/

public class HttpUtil {

/**

* 向指定URL发送GET方法的请求

*

* @param url

* 发送请求的URL

* @param param

* 请求参数,请求参数应该是 name1=value1name2=value2 的形式。

* @return String 所代表远程资源的响应结果

*/

public static String get(String url,String param){

String result = "";

BufferedReader in = null;

try {

String urlNameString = url + "?" + param;

//System.out.println(urlNameString);

URL realUrl = new URL(urlNameString);

// 打开和URL之间的连接

URLConnection connection = realUrl.openConnection();

// 设置通用的请求属性

connection.setRequestProperty("accept", "*/*");

connection.setRequestProperty("connection", "Keep-Alive");

connection.setRequestProperty("user-agent",

"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");

// 建立实际的连接

connection.connect();

// 获取所有响应头字段

MapString, ListString map = connection.getHeaderFields();

// 遍历所有的响应头字段

/*for (String key : map.keySet()) {

System.out.println(key + "---" + map.get(key));

}*/

// 定义 BufferedReader输入流来读取URL的响应

in = new BufferedReader(new InputStreamReader(

connection.getInputStream()));

String line;

while ((line = in.readLine()) != null) {

result += line;

}

} catch (Exception e) {

System.out.println("发送GET请求出现异常!" + e);

e.printStackTrace();

}

// 使用finally块来关闭输入流

finally {

try {

if (in != null) {

in.close();

}

} catch (Exception e2) {

e2.printStackTrace();

}

}

return result;

}

}

如何用java实现抓取商城商品信息到自己的页面上来!!! 求解啊,大神们!!

对于加密的网站还没去研究,不知道能不能抓取,现在只是对一些没有加密的网站进行网页数据抓取。刚刚开始写的时候以为很多网站都能抓取,但是发现很多都加密了,本来以为一些地址可以通过网页数据检测工具测出他的数据变化,但是只能监测到一些通过js显示的数据,依然不能抓取到加密的网站。嗨,这个问题以后再说吧。

[java]

import java.net.* ;

import java.io.* ;

import java.util.regex.* ;

public class Capture{

public static void main(String args[])throws Exception{

System.out.println("*************************手机号查询************************") ;

System.out.println("我的位置是:" + new GrabMobile().grabMobileLocation("15023141745")) ;

System.out.println("手机卡类型是:" + new GrabMobile().grabMobileType("15023141745")) ;

System.out.println("我的邮编是:" + new GrabMobile().grabMobilePost("15023141745")) ;

System.out.println("*************************身份证查询************************") ;

System.out.println("我的性别是:" + new GrabIdentity().grabIdentitySex("362203199208243575")) ;

System.out.println("我的生日是:" + new GrabIdentity().grabIdentityBirth("362203199208243575")) ;

System.out.println("我的家乡是:" + new GrabIdentity().grabIdentityHome("362203199208243575")) ;

}

}

class GrabMobile{

public String grabMobileLocation(String m)throws Exception{

String strUrl = ";mobile=" + m;

URL url = new URL(strUrl) ;

HttpURLConnection httpUrlCon = (HttpURLConnection)url.openConnection() ;

InputStreamReader inRead = new InputStreamReader(httpUrlCon.getInputStream(),"GBK") ;

BufferedReader bufRead = new BufferedReader(inRead) ;

StringBuffer strBuf = new StringBuffer() ;

String line = "" ;

while ((line = bufRead.readLine()) != null) {

strBuf.append(line);

}

String strStart = "卡号归属地" ;

String strEnd = "卡 类 型";

String strAll = strBuf.toString() ;

int start = strAll.indexOf(strStart) ;

int end = strAll.indexOf(strEnd) ;

String result = strAll.substring(start+42,end-33) ;

result = drawChMob(result) ;

return result ;

}

public String grabMobileType(String m)throws Exception{

String strUrl = ";mobile=" + m;

URL url = new URL(strUrl) ;

HttpURLConnection httpUrlCon = (HttpURLConnection)url.openConnection() ;

InputStreamReader inRead = new InputStreamReader(httpUrlCon.getInputStream(),"GBK") ;

BufferedReader bufRead = new BufferedReader(inRead) ;

StringBuffer strBuf = new StringBuffer() ;

String line = "" ;

while ((line = bufRead.readLine()) != null) {

strBuf.append(line);

}

String strStart = "卡 类 型" ;

String strEnd = "TD align=\"center\"区 号/TD";

String strAll = strBuf.toString() ;

int start = strAll.indexOf(strStart) ;

int end = strAll.indexOf(strEnd) ;

String result = strAll.substring(start+12,end) ;

result = drawChMob(result) ;

result = result.substring(1) ;

return result ;

}

public String grabMobilePost(String m)throws Exception{

String strUrl = ";mobile=" + m;

URL url = new URL(strUrl) ;

HttpURLConnection httpUrlCon = (HttpURLConnection)url.openConnection() ;

InputStreamReader inRead = new InputStreamReader(httpUrlCon.getInputStream(),"GBK") ;

BufferedReader bufRead = new BufferedReader(inRead) ;

StringBuffer strBuf = new StringBuffer() ;

String line = "" ;

while ((line = bufRead.readLine()) != null) {

strBuf.append(line);

}

String strStart = "邮 编" ;

String strEnd = "更详细的..";

String strAll = strBuf.toString() ;

int start = strAll.indexOf(strStart) ;

int end = strAll.indexOf(strEnd) ;

String result = strAll.substring(start+40,end-55) ;

return result ;

}

public String drawChMob(String str){

StringBuffer strBuf = new StringBuffer() ;

String regex="([\u4e00-\u9fa5]+)";

Matcher matcher = Pattern.compile(regex).matcher(str);

while(matcher.find()){

strBuf.append(matcher.group(0)).toString() ;

}

return strBuf.toString() ;

}

}

class GrabIdentity{

public String grabIdentitySex(String userid)throws Exception{

String strUrl = ";userid=" + userid + "B1=%B2%E9+%D1%AF";

URL url = new URL(strUrl) ;

HttpURLConnection httpUrlCon = (HttpURLConnection)url.openConnection() ;

InputStreamReader inRead = new InputStreamReader(httpUrlCon.getInputStream(),"GBK") ;

BufferedReader bufRead = new BufferedReader(inRead) ;

StringBuffer strBuf = new StringBuffer() ;

String line = "" ;

while ((line = bufRead.readLine()) != null) {

strBuf.append(line);

}

String strStart = " 别" ;

String strEnd = "出生日期";

String strAll = strBuf.toString() ;

int start = strAll.indexOf(strStart) ;

int end = strAll.indexOf(strEnd) ;

String result = strAll.substring(start+7,end) ;

result = drawCh(result) ;

return result ;

}

public String grabIdentityBirth(String userid)throws Exception{

String strUrl = ";userid=" + userid + "B1=%B2%E9+%D1%AF";

URL url = new URL(strUrl) ;

HttpURLConnection httpUrlCon = (HttpURLConnection)url.openConnection() ;

InputStreamReader inRead = new InputStreamReader(httpUrlCon.getInputStream(),"GBK") ;

BufferedReader bufRead = new BufferedReader(inRead) ;

StringBuffer strBuf = new StringBuffer() ;

String line = "" ;

while ((line = bufRead.readLine()) != null) {

strBuf.append(line);

}

String strStart = "出生日期:/tdtd class=\"tdc2\"" ;

String strEnd = "/tdtrtrtd class=";

String strAll = strBuf.toString() ;

int start = strAll.indexOf(strStart) ;

int end = strAll.indexOf(strEnd) ;

String result = strAll.substring(start+27,end) ;

return result ;

}

public String grabIdentityHome(String userid)throws Exception{

String strUrl = ";userid=" + userid + "B1=%B2%E9+%D1%AF";

URL url = new URL(strUrl) ;

HttpURLConnection httpUrlCon = (HttpURLConnection)url.openConnection() ;

InputStreamReader inRead = new InputStreamReader(httpUrlCon.getInputStream(),"GBK") ;

BufferedReader bufRead = new BufferedReader(inRead) ;

StringBuffer strBuf = new StringBuffer() ;

String line = "" ;

while ((line = bufRead.readLine()) != null) {

strBuf.append(line);

}

String strStart = "证 地:/tdtd class=\"tdc2\"" ;

String strEnd = "br//td/trtrtd class=\"tdc3\" valign=\"top\" align=\"right\"部分或" ;

String strAll = strBuf.toString() ;

int start = strAll.indexOf(strStart) ;

int end = strAll.indexOf(strEnd) ;

String result = strAll.substring(start+31,end) ;

return result ;

}

public String drawCh(String str){

StringBuffer strBuf = new StringBuffer() ;

String regex="([\u4e00-\u9fa5]+)";

Matcher matcher = Pattern.compile(regex).matcher(str);

if(matcher.find()){

str = strBuf.append(matcher.group(0)).toString() ;

}

return str ;

}

}

待会传上改装成的android小程序,可以手机号查询和身份证查询。

Java~有哪位大虾可以帮我写一个小程序呀,用Java做一个界面,上面有四个按钮分别是红色,黄色,蓝色,退出,

import java.awt.Color;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

public class Screen{

public static void main(String args[]){

new Win();

}

static class Win extends JFrame implements ActionListener{

JPanel jp = new JPanel();

JButton jb[] = new JButton[4];

public Win(){

this.setBounds(0, 0, 320, 320);

Color c[] = {Color.red,Color.yellow,Color.blue};

jp.setBackground(Color.black);

for(int i = 0 ; i 4 ; i++){

jb[i] = new JButton();

if(i!=3){

jb[i].setBackground(c[i]);

}else{

jb[i].setText("退出");

}

jb[i].addActionListener(this);

jp.add(jb[i]);

}

this.add(jp);

this.setVisible(true);

}

public void actionPerformed(ActionEvent e) {

if(!((JButton)e.getSource()).getText().equals("退出")){//如果不是退出按钮,则换颜色

jp.setBackground(((JButton)e.getSource()).getBackground());

}

else

System.exit(0);//退出

}

}

}


网页名称:小程序商城java代码,小程序商城源代码免费下载
标题链接:http://cqcxhl.cn/article/dseidjp.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP