一。Decoder

 /(一)Decoder
func DecoderExample(){
const jsonStream = `
{ "Name" : "Ed" , "Text" : "Knock knock." }
{ "Name" : "Sam" , "Text" : "Who's there?" }
{ "Name" : "Ed" , "Text" : "Go fmt." }
{ "Name" : "Sam" , "Text" : "Go fmt who?" }
{ "Name" : "Ed" , "Text" : "Go fmt yourself!" }
`
type Message struct {
Name , Text string
}
dec := json. NewDecoder ( strings. NewReader ( jsonStream ) )
for {
var m Message
if err := dec. Decode ( & m ) ; err == io. EOF {
break
} else if err != nil {
log . Fatal ( err )
}
fmt. Printf ( "%s: %s \n " , m. Name , m. Text )
/*
执行结果:
Ed: Knock knock.
Sam: Who's there?
Ed: Go fmt.
Sam: Go fmt who?
Ed: Go fmt yourself!
*/
}
}

二。对象转换为JSON的方法(函数)为 json.Marshal()

 //(二)Marshal序列化JSON格式(对象-》JSON)
func marshalExample(){
type ColorGroup struct {
ID int
Name string
Colors [ ] string
}
group := ColorGroup {
ID : ,
Name : "Reds" ,
Colors : [ ] string { "Crimson" , "Red" , "Ruby" , "Maroon" } ,
}
b , err := json. Marshal ( group )
if err != nil {
fmt. Println ( "error:" , err )
}
os. Stdout . Write ( b )
/*
运行结果:
{"ID":1,"Name":"Reds","Colors":["Crimson","Red","Ruby","Maroon"]}
*/
}

三。JSON 转换回对象的方法(函数)为 json.Unmarshal()

 //(三)unmarshal:反序列化json格式(JSON->对象)
func unmarshalExample(){
var jsonBlob = [ ] byte ( ` [
{ "Name" : "Platypus" , "Order" : "Monotremata" } ,
{ "Name" : "Quoll" , "Order" : "Dasyuromorphia" }
] ` )
type Animal struct {
Name string
Order string
}
var animals [ ] Animal
err := json. Unmarshal ( jsonBlob , & animals )
if err != nil {
fmt. Println ( "error:" , err )
}
fmt. Printf ( "%+v" , animals )
/*
运行结果:
[{Name:Platypus Order:Monotremata} {Name:Quoll Order:Dasyuromorphia}]
*/
}

四。项目需求

参照go http传递json数据:https://blog.csdn.net/lanyang123456/article/details/78702873

golang学习室:https://www.kancloud.cn/digest/batu-go/153529

需求:
go调用java语言,传递json格式参数,并接收java返回的响应数据。(go建立http连接,传递请求参数,接收返回结果)

java端,返回json格式数据

1。Controller

 package com.csvalue.controller;
import cfca.ra.common.vo.request.CertServiceRequestVO;
import cfca.ra.common.vo.request.TxRequestVO;
import cfca.ra.common.vo.response.CertServiceResponseVO;
import cfca.ra.common.vo.response.TxResponseVO;
import cfca.ra.toolkit.RAClient;
import cfca.ra.toolkit.exception.RATKException;
import com.alibaba.fastjson.JSON;
import com.csvalue.common.ResponseCode;
import com.csvalue.common.ResponseResult;
import com.csvalue.model.CertificateParam;
import com.csvalue.model.CertificateResult;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; @Controller
@RequestMapping("/cfca")
public class ApplyCertificateController { final org.slf4j.Logger log = LoggerFactory.getLogger(getClass()); @ResponseBody
@RequestMapping(value = "/applyCertificate", method = {RequestMethod.GET,RequestMethod.POST})
public ResponseResult<CertificateResult> applyCertificate(@RequestBody CertificateParam certificateParam) {
log.info("接收到获取证书的参数:",JSON.toJSONString(certificateParam));
CertificateResult certificateResult=new CertificateResult();
try {
RAClient client = ApplyCertificateConfig.getRAClient();
TxRequestVO txRequestVO = new TxRequestVO();
txRequestVO.setTxCode("");
TxResponseVO txResponseVO = (TxResponseVO) client.process(txRequestVO);
if(!"".equals(txResponseVO.getResultCode())){
return ResponseResult.error(ResponseCode.DISCONNECT);
}
//设置请求参数
CertServiceRequestVO certServiceRequestVO=setCertServiceRequestVO(certificateParam);
//接收返回结果
CertServiceResponseVO certServiceResponseVO = (CertServiceResponseVO) client.process(certServiceRequestVO); log.info("ResultCode:",certServiceResponseVO.getResultCode()); //
log.info("resultMsg:",certServiceResponseVO.getResultMessage()); //成功
//成功获取证书
if (RAClient.SUCCESS.equals(certServiceResponseVO.getResultCode())) {
//设置返回结果
certificateResult=setCertificateResult(certServiceResponseVO);
log.info("返回申请证书结果:",JSON.toJSON(certificateResult));
}else if("".equals(certServiceResponseVO.getResultCode())){
return ResponseResult.error(ResponseCode.NO_MATCH_CERTIFICATE);
}else if("".equals(certServiceResponseVO.getResultCode())){
return ResponseResult.error(ResponseCode.PUBKEY_IS_USED);
}else{
return ResponseResult.error(ResponseCode.FAIL);
}
} catch (RATKException e) {
log.error(e.getMessage(), e);
return ResponseResult.error(ResponseCode.FAIL);
}
return ResponseResult.success(certificateResult);
} /*设置请求参数*/
public CertServiceRequestVO setCertServiceRequestVO(CertificateParam certificateParam){
CertServiceRequestVO certServiceRequestVO = new CertServiceRequestVO();
certServiceRequestVO.setTxCode("");
certServiceRequestVO.setCaName(certificateParam.getCaName());
certServiceRequestVO.setCertType(certificateParam.getCertType());
certServiceRequestVO.setCustomerType(certificateParam.getCustomerType());
certServiceRequestVO.setUserName(certificateParam.getUserName());
certServiceRequestVO.setIdentType(certificateParam.getIdentType());
certServiceRequestVO.setIdentNo(certificateParam.getIdentNo());
certServiceRequestVO.setKeyLength(certificateParam.getKeyLength());
certServiceRequestVO.setKeyAlg(certificateParam.getKeyAlg());
certServiceRequestVO.setBranchCode(certificateParam.getBranchCode());
certServiceRequestVO.setEmail(certificateParam.getEmail());
certServiceRequestVO.setP10(certificateParam.getP10());
return certServiceRequestVO;
} /*设置返回结果*/
public CertificateResult setCertificateResult(CertServiceResponseVO certServiceResponseVO){
CertificateResult certificateResult=new CertificateResult();
certificateResult.setDn(certServiceResponseVO.getDn());
certificateResult.setSequenceNo(certServiceResponseVO.getSequenceNo());
certificateResult.setSerialNo(certServiceResponseVO.getSerialNo());
certificateResult.setSignatureCert(certServiceResponseVO.getSignatureCert());
certificateResult.setStartTime(certServiceResponseVO.getStartTime());
certificateResult.setEndTime(certServiceResponseVO.getEndTime());
certificateResult.setEncryptionCert(certServiceResponseVO.getEncryptionCert());
certificateResult.setEncryptionCertSub(certServiceResponseVO.getEncryptionCertSub());
certificateResult.setSignatureCert(certServiceResponseVO.getSignatureCert());
certificateResult.setEncryptionPrivateKey(certServiceResponseVO.getEncryptionPrivateKey());
certificateResult.setEncryptionPrivateKeySub(certServiceResponseVO.getEncryptionPrivateKeySub());
return certificateResult;
}
}

2。model

 package com.csvalue.model;

 import java.io.Serializable;

 public class CertificateParam implements Serializable {
private String caName;
private String certType;
private String customerType;
private String userName;
private String identType;
private String identNo;
private String keyAlg;
private String keyLength;
private String branchCode;
private String email;
private String p10; public String getCaName() {
return caName;
} public void setCaName(String caName) {
this.caName = caName;
} public String getCertType() {
return certType;
} public void setCertType(String certType) {
this.certType = certType;
} public String getCustomerType() {
return customerType;
} public void setCustomerType(String customerType) {
this.customerType = customerType;
} public String getUserName() {
return userName;
} public void setUserName(String userName) {
this.userName = userName;
} public String getIdentType() {
return identType;
} public void setIdentType(String identType) {
this.identType = identType;
} public String getIdentNo() {
return identNo;
} public void setIdentNo(String identNo) {
this.identNo = identNo;
} public String getKeyAlg() {
return keyAlg;
} public void setKeyAlg(String keyAlg) {
this.keyAlg = keyAlg;
} public String getKeyLength() {
return keyLength;
} public void setKeyLength(String keyLength) {
this.keyLength = keyLength;
} public String getBranchCode() {
return branchCode;
} public void setBranchCode(String branchCode) {
this.branchCode = branchCode;
} public String getEmail() {
return email;
} public void setEmail(String email) {
this.email = email;
} public String getP10() {
return p10;
} public void setP10(String p10) {
this.p10 = p10;
}
}
 package com.csvalue.model;

 import java.io.Serializable;

 /*
* 申请证书返回结果
* */
public class CertificateResult implements Serializable {
private String dn;
private String serialNo;
private String signatureCert;
private String sequenceNo;
private String encryptionCert;
private String encryptionPrivateKey;
private String signatureCertSub;
private String encryptionCertSub;
private String encryptionPrivateKeySub;
private String startTime;
private String endTime; public String getDn() {
return dn;
} public void setDn(String dn) {
this.dn = dn;
} public String getSerialNo() {
return serialNo;
} public void setSerialNo(String serialNo) {
this.serialNo = serialNo;
} public String getSignatureCert() {
return signatureCert;
} public void setSignatureCert(String signatureCert) {
this.signatureCert = signatureCert;
} public String getSequenceNo() {
return sequenceNo;
} public void setSequenceNo(String sequenceNo) {
this.sequenceNo = sequenceNo;
} public String getStartTime() {
return startTime;
} public void setStartTime(String startTime) {
this.startTime = startTime;
} public String getEndTime() {
return endTime;
} public void setEndTime(String endTime) {
this.endTime = endTime;
} public String getEncryptionCert() {
return encryptionCert;
} public void setEncryptionCert(String encryptionCert) {
this.encryptionCert = encryptionCert;
} public String getEncryptionPrivateKey() {
return encryptionPrivateKey;
} public void setEncryptionPrivateKey(String encryptionPrivateKey) {
this.encryptionPrivateKey = encryptionPrivateKey;
} public String getSignatureCertSub() {
return signatureCertSub;
} public void setSignatureCertSub(String signatureCertSub) {
this.signatureCertSub = signatureCertSub;
} public String getEncryptionCertSub() {
return encryptionCertSub;
} public void setEncryptionCertSub(String encryptionCertSub) {
this.encryptionCertSub = encryptionCertSub;
} public String getEncryptionPrivateKeySub() {
return encryptionPrivateKeySub;
} public void setEncryptionPrivateKeySub(String encryptionPrivateKeySub) {
this.encryptionPrivateKeySub = encryptionPrivateKeySub;
}
}

3。返回结果:

 {
"code": ,
"msg": "成功",
"data": {
"dn": "bb",
"serialNo": "",
"signatureCert": "aa",
"sequenceNo": "",
"encryptionCert": "",
"encryptionPrivateKey": "",
"signatureCertSub": null,
"encryptionCertSub": null,
"encryptionPrivateKeySub": null,
"startTime": "",
"endTime": ""
}
}

******注意:******

使用postman测试java接口,是否能够成功调用

SpringMVC @RequestBody请求参数在postman中的请求

Step1:设置header中两个参数

Step2:设置json参数

go端,调用java端,传递请求参数及接收返回的JSON数据

1。callJava.go

 package lib

 import (
"net/http"
"fmt"
"git.jd.com/baas/identity/cachain/common"
"encoding/json"
"strings"
"io/ioutil"
"log"
"git.jd.com/baas/identity/cachain/api"
) type EnrollCfca struct {
AuditId int `json:"auditId"`
CaName string `json:"caName"`
CertType string `json:"certType"`
CustomerType string `json:"customerType"`
UserName string `json:"userName"`
IdentType string `json:"identType"`
IdentNo string `json:"identNo"`
KeyAlg string `json:"keyAlg"`
KeyLength string `json:"keyLength"`
BranchCode string `json:"branchCode"`
Email string `json:"email"`
P10 string `json:"p10"`
} type ResultCfca struct{
Code int `json:"code"`
Msg string `json:"msg"`
Data api.CfcaInfo `json:"data"`
} func enrollCFCA(w http.ResponseWriter, r *http.Request, h UserHandler) {
logger.Debugf("Enter enrollCFCA...")
defer logger.Debugf("Leave enrollCFCA...") SetHeader(w) var errMsg string rareReq := EnrollCfca{}
if err := ReadRequest(r, &rareReq); err != nil {
logger.Errorf("read request err:%s", err.Error())
errMsg = fmt.Sprintf("Failure to read body:%s", err.Error())
common.SendResponse(w, common.ERR_READ_REQUEST, errMsg)
return
} logger.Debugf("user enrollCFCA info: %+v", rareReq) //1。调用java,从CFCA获取证书
resultCfca := callJava(rareReq) if resultCfca.Code != {
common.SendResponse(w, common.ERR_FAILURE, resultCfca.Msg)
return
} resultCfca.Data.AuditId=rareReq.AuditId //开启一个事务
tx, err := h.DBConn.Begin()
if err != nil {
logger.Errorf("Fail to begin a transaction,err:%s", err.Error())
common.SendResponse(w, common.ERR_SQL_TRANSACTION, "Fail to begin transacton,err:"+err.Error())
return
} //1.将数据存储到数据库
err = h.SaveCfcaDataToDB(resultCfca.Data) if err != nil {
logger.Errorf("Error insert cfcainfo into database err:%s", err.Error())
common.SendResponse(w, common.ERR_SQL_INSERT, "Fail insert cfcainfo!user:"+rareReq.UserName+",err:"+err.Error())
tx.Rollback()
return
}
tx.Commit()
return
}
//调用java
func callJava(javaParam EnrollCfca) ResultCfca{
url := "http://localhost:8888/cfca/applyCertificate"
contentType := "application/json;charset=utf-8"
javaJsonParam, errs := json.Marshal(javaParam) //转换成JSON返回的是byte[]
if errs != nil {
fmt.Println(errs.Error())
}
fmt.Println(string(javaJsonParam)) //发送请求
req, err := http.NewRequest("POST", url, strings.NewReader(string(javaJsonParam)))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", contentType)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
//响应
response, err := ioutil.ReadAll(resp.Body)
fmt.Println("response:", string(response))
if err != nil {
log.Println("Read failed:", err)
return ResultCfca{}
}
log.Println("response:", string(response)) //cfca返回结果
resultcfca := ResultCfca{}
json.Unmarshal([]byte(string(response)), &resultcfca) //json解析到结构体里面
fmt.Println("resultcfca",resultcfca) //输入结构体
fmt.Println("code",resultcfca.Code) return resultcfca
}

2。api.go

 package api
type CfcaInfo struct {
AuditId int `db:"auditId" json:"auditId"`
Dn string `db:"dn" json:"dn"`
SerialNo string `db:"serialNo" json:"serialNo"`
SignatureCert string `db:"signatureCert" json:"signatureCert"`
SequenceNo string `db:"sequenceNo" json:"sequenceNo"`
StartTime string `db:"startTime" json:"startTime"`
EndTime string `db:"endTime" json:"endTime"`
EncryptionCert string `db:"encryptionCert" json:"encryptionCert"`
EncryptionPrivateKey string `db:"encryptionPrivateKey" json:"encryptionPrivateKey"`
SignatureCertSub string `db:"signatureCertSub" json:"signatureCertSub"`
EncryptionCertSub string `db:"encryptionCertSub" json:"encryptionCertSub"`
EncryptionPrivateKeySub string `db:"encryptionPrivateKeySub" json:"encryptionCertSub"`
}

3。ra.go

 package ra
const (saveEnrollCfca = `INSERT INTO cfca_info(auditId,dn,serialNo,signatureCert,sequenceNo,encryptionCert,encryptionPrivateKey,signatureCertSub,encryptionCertSub,encryptionPrivateKeySub,startTime,endTime)
VALUES(:auditId,:dn,:serialNo,:signatureCert,:sequenceNo,:encryptionCert,:encryptionPrivateKey,:signatureCertSub,:encryptionCertSub,:encryptionPrivateKeySub,:startTime,:endTime)`
)
type DBConn struct {
*sqlx.DB
} func (d *DBConn) SaveCfcaDataToDB(enrollResult api.CfcaInfo) error {
logger.Debugf("Enter SaveCfcaDataToDB ...")
defer logger.Debugf("Leave SaveCfcaDataToDB ...") err := d.checkDB()
if err != nil {
logger.Errorf("check db err:%s", err.Error())
return err
} res, err := d.NamedExec(saveEnrollCfca, enrollResult) if err != nil {
logger.Errorf("Error adding cfcaInfo %s to the database: %s", enrollResult.AuditId, err)
return err
} numRowsAffected, err := res.RowsAffected()
if err != nil {
logger.Errorf("Error adding cfcaInfo %s affected err: %s", enrollResult.AuditId, err)
return err
} if numRowsAffected == {
return fmt.Errorf("Failed to add cfcaInfo %s to the database:", enrollResult.AuditId)
} if numRowsAffected != {
return fmt.Errorf("Expected to add one record to the datab ase, but %d records were added", numRowsAffected)
}
return nil
}

五。项目需求

参考博客:

http://www.cnblogs.com/Goden/p/4658287.html

http://www.01happy.com/golang-http-client-get-and-post/

项目需求:
go调用java传递string类型参数

Java端代码:

  /*
* 撤销证书
* */
@ResponseBody
@RequestMapping(value = "/revokeCertificate", method = RequestMethod.POST)
public ResponseResult revokeCertificate(String dn) {
log.info("接收到撤销的dn参数:", dn);
try {
RAClient client = CertificateConfig.getRAClient();
CertServiceRequestVO certServiceRequestVO = new CertServiceRequestVO();
certServiceRequestVO.setTxCode("");
// certServiceRequestVO.setLocale(locale);
certServiceRequestVO.setDn(dn);
CertServiceResponseVO certServiceResponseVO = (CertServiceResponseVO) client.process(certServiceRequestVO);
log.info("撤销证书返回状态码和状态值:",certServiceResponseVO.getResultCode(),certServiceResponseVO.getResultMessage());
if(!RAClient.SUCCESS.equals(certServiceResponseVO.getResultCode())){ //成功状态
return ResponseResult.error(Integer.parseInt(certServiceResponseVO.getResultCode()),certServiceResponseVO.getResultMessage());
}
System.out.println(certServiceResponseVO.getResultCode());
System.out.println(certServiceResponseVO.getResultMessage());
} catch (RATKException e) {
log.error(e.getMessage(), e);
return ResponseResult.error(ResponseCode.FAIL);
}
return ResponseResult.success(ResponseCode.OK);
}

PostMan测试

Go端调用java实现传递url和参数

 /*
吊销证书
*/
func revokeCfcaCert(userName string, h UserHandler) error {
logger.Debugf("enter revokeCert")
defer logger.Debugf("leave revokeCert") if userName == "" {
return errors.New("userName is null")
}
//1.根据用户名查询dn值
cfcaInfo, err := h.DBGetCfcaInfo(userName) log.Println("获取cfcaInfo:", cfcaInfo) if err != nil {
return err
} //2.调用java撤销cfca证书
resultCfca := callJavaRevoke(cfcaInfo.Dn) log.Println("吊销证书resultCfca:", resultCfca) if resultCfca.Code != {
//return fmt.Errorf(resultCfca.Msg)
return errors.New(resultCfca.Msg)
}
return nil
} func callJavaRevoke(dn string) ResultCfca {
url := "http://localhost:8888/cfca/revokeCertificate"
contentType := "application/x-www-form-urlencoded"
//发送请求
req, err := http.NewRequest("POST", url, strings.NewReader("dn="+dn))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", contentType)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
//响应
response, err := ioutil.ReadAll(resp.Body)
fmt.Println("response:", string(response))
if err != nil {
log.Println("Read failed:", err)
return ResultCfca{}
}
log.Println("response:", string(response)) //cfca返回结果
resultcfca := ResultCfca{}
json.Unmarshal([]byte(string(response)), &resultcfca) //json解析到结构体里面
fmt.Println("resultcfca", resultcfca) //输入结构体
fmt.Println("code", resultcfca.Code)
return resultcfca
}

Go语言入门篇-JSON&http调用的更多相关文章

  1. Go语言入门篇-jwt(json web token)权限验证

    一.token.cookie.session的区别 1.cookie Cookie总是保存在客户端中,按在客户端中的存储位置,可分为内存Cookie和硬盘Cookie. 内存Cookie由浏览器维护, ...

  2. Go语言入门篇-gRPC基于golang & java简单实现

    一.什么是RPC 1.简介: RPC:Remote Procedure Call,远程过程调用.简单来说就是两个进程之间的数据交互. 正常服务端的接口服务是提供给用户端(在Web开发中就是浏览器)或者 ...

  3. Go语言入门篇-使用Beego构建完整web应用

    使用Beego构建完整web应用 一.GO简介(Beego应用go编写) 1.为什么用GO (1).语法简单 (2).简洁的并发 (3).开发和执行效率快(编译型语言) 2.GO语言环境 下载go & ...

  4. Go语言入门篇-项目常见用法&语法

    一.导入包用法: //_表示仅执行该包下的init函数(不需要整个包导入) import _ "git.xx.xx/baases/identity/cachain/version" ...

  5. Go语言入门篇-基本类型排序和 slice 排序

    参见博客:https://blog.csdn.net/u010983881/article/details/52460998 package main import ( "sort" ...

  6. 优雅的go语言--入门篇

    1.特点 1.静态类型,编译型的开源语言 2.脚本华的语法,支持多种编程范式(函数式&面向对象) 3.原生,给力的并发编程的支持 2.优势 1.脚本化的语法 2.静态类型+编译型,程序运行速度 ...

  7. 明解C语言 入门篇 第五章答案

    练习5-1 /* 依次把1.2.3.4.5 赋值给数组的每个元素并显示(使用for语句) */ #include <stdio.h> int main(void) { int i; ]; ...

  8. Go语言入门篇-网络经验

    Go语言学习手册 golang*看云  golang圣经 wuYinIO 1.go语言开发中的坑 go新手容易犯的三个致命错误   Golang 需要避免踩的 50 个坑 2.go语言数据类型 map ...

  9. Go语言入门篇-基本数据类型

    一.程序实体与关键字 任何Go语言源码文件都由若干个程序实体组成的.在Go语言中,变量.常量.函数.结构体和接口被统称为“程序实体”,而它们的名字被统称为“标识符”. 标识符可以是任何Unicode编 ...

随机推荐

  1. [转]Normal Map中的值, Tangent Space, 求算 Tangent 与 Binormal 与 TBN Matrix

    原文出处 https://www.cnblogs.com/lookof/p/3509970.html - Normal Map中的值 -   有没有想过,Normal Map(法线贴图)为什么看上去都 ...

  2. HDU 6102 - GCDispower | 2017 Multi-University Training Contest 6

    个人感觉题解的复杂度很玄,参不透,有没有大佬讲解一下- - /* HDU 6102 - GCDispower [ 数论,树状数组] | 2017 Multi-University Training C ...

  3. js+下载文件夹

    一.此方法火狐有些版本是不支持的 window.location.href = 'https://*****.oss-cn-**.aliyuncs.com/*********'; 二.为了解决火狐有些 ...

  4. CF1207B

    CF1207B-Square Filling 题意: 两个矩阵a,b,已知矩阵b,每次能修改b矩阵中相邻的四个格(b为空矩阵),使b变为a 解法: 枚举矩阵中的1,按题意修改,并把改过的四个点都标记一 ...

  5. [51nod1789] 跑得比谁都快

    题面 题解 设\(f[i]\)为根节点到\(i\)的最小耗时 设\(S\)为\(i\)的祖先集合, 可以得到 \[ f[i] = min(f[j] + (i - j)^p),j \in S \] 对于 ...

  6. ps 证件照制作

    自己制作证件照,再通过印鸽等服务打印邮寄,个人感觉还是比较方便实惠. 使用ps的定义图案和填充功能(ps精简版) 定义图案 1,打开1寸照片 2,图像=>图像大小,可选去掉约束比例 1寸:2.5 ...

  7. Linux设备驱动程序 之 装载和卸载模块

    前置说明 本文例子中涉及两个模块hello.ko和world.ko,其中hello导出符号供world使用: insmod 该命令将模块的代码和数据装入内核,然后使用内核的符号表继续模块中任何未解析的 ...

  8. Google 插件的使用

    每次看英文网页或者文档的时候总会碰到不认识单词,就想能不能选中单词就可以显示翻译?于是就安装Google浏览器的翻译插件,总的来说,蛮繁琐的. 1.先安装谷歌访问助手 (1.)直接百度谷歌访问助手 ( ...

  9. django-admin 配置

    本节讲django-admin配置方法: 1.在工程配置文件中(settings.py)中启用admin组件.确保有如下两行配置: 2.执行数据库迁移的命令,确保对应的表在数据库中已经添加了 #pyt ...

  10. curl 使用笔记

    一.使用案例 curl -H "cookie:userName=shangyy" www.baidu.com 二.使用 1.从Netscape的网页服务器上获得该网站的主页: cu ...