1 2 3 4 |
curl -H "Content-Type: application/json" \ -X POST \ -d '{"username":"xyz","password":"xyz"}' \ http://localhost:8000/api/login |
-d 后面的参数,一定要是单引号在外面,双引号在里面。
1 2 3 4 |
curl -H "Content-Type: application/json" \ -X POST \ -d '{"username":"xyz","password":"xyz"}' \ http://localhost:8000/api/login |
-d 后面的参数,一定要是单引号在外面,双引号在里面。
1 2 |
git config --global alias.lg <span class="token string">"log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"</span> |
开发需求把停车场实时信息发布到大屏幕上去,大屏的厂家给了个dll开发包,被坑死,要求使用rtf文档才能发布。
找了一圈,最后发现iText可以做这个事。
加入依赖包:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>2.1.7</version> </dependency> <dependency> <groupId>com.lowagie</groupId> <artifactId>itext-rtf</artifactId> <version>2.1.7</version> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itext-asian</artifactId> <version>5.2.0</version> </dependency> |
尽量不要更改版本。
给一段简单的生成的代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
// 创建word文档,并设置纸张的大小 Document document = new Document(PageSize.A4); document.setMargins(50, 50, 50, 50); File dir = new File("d:/hxtx/carInfoRtfFiles/"); if (!dir.exists()) { dir.mkdirs(); } RtfWriter2.getInstance(document, new FileOutputStream("d:/hxtx/carInfoRtfFiles/a.rtf")); document.open(); Paragraph blank = new Paragraph(" ", new Font(Font.NORMAL, 22, Font.UNDEFINED, new Color(255, 0, 0))); blank.setAlignment(1); Paragraph blank1 = new Paragraph(" ", new Font(Font.NORMAL, 22, Font.UNDEFINED, new Color(255, 0, 0))); blank1.setAlignment(1); Paragraph title = new Paragraph("实时停车信息", new Font(Font.NORMAL, 28, Font.BOLD, new Color(255, 0, 0))); title.setAlignment(1); document.add(title); document.add(blank); Paragraph wulian = new Paragraph("五莲山停车场", new Font(Font.NORMAL, 22, Font.UNDEFINED, new Color(255, 0, 0))); wulian.setAlignment(0); document.add(wulian); document.add(blank1); Paragraph wulianContent = new Paragraph(); Phrase wulian1 = new Phrase("东门剩余:", new Font(Font.NORMAL, 18, Font.UNDEFINED, new Color(255, 0, 0))); Phrase wulian2 = new Phrase(wuliandong + "", new Font(Font.NORMAL, 28, Font.BOLD, new Color(0, 0, 255))); Phrase wulian3 = new Phrase("个,西门剩余:", new Font(Font.NORMAL, 18, Font.UNDEFINED, new Color(255, 0, 0))); Phrase wulian4 = new Phrase(wulianxi + "", new Font(Font.NORMAL, 28, Font.BOLD, new Color(0, 0, 255))); Phrase wulian5 = new Phrase("个", new Font(Font.NORMAL, 18, Font.UNDEFINED, new Color(255, 0, 0))); wulianContent.add(wulian1); wulianContent.add(wulian2); wulianContent.add(wulian3); wulianContent.add(wulian4); wulianContent.add(wulian5); document.add(wulianContent); document.add(blank); Paragraph jiuxian = new Paragraph("九仙山停车场", new Font(Font.NORMAL, 22, Font.UNDEFINED, new Color(255, 0, 0))); jiuxian.setSpacingBefore(12); jiuxian.setAlignment(0); document.add(jiuxian); document.add(blank1); Paragraph jiuxianContent = new Paragraph(); Phrase jiuxian1 = new Phrase("东门剩余:", new Font(Font.NORMAL, 18, Font.UNDEFINED, new Color(255, 0, 0))); Phrase jiuxian2 = new Phrase(jiuxiandong + "", new Font(Font.NORMAL, 28, Font.BOLD, new Color(255, 255, 0))); Phrase jiuxian3 = new Phrase("个,西门剩余:", new Font(Font.NORMAL, 18, Font.UNDEFINED, new Color(255, 0, 0))); Phrase jiuxian4 = new Phrase(jiuxianxi + "", new Font(Font.NORMAL, 28, Font.BOLD, new Color(255, 255, 0))); Phrase jiuxian5 = new Phrase("个", new Font(Font.NORMAL, 18, Font.UNDEFINED, new Color(255, 0, 0))); jiuxianContent.add(jiuxian1); jiuxianContent.add(jiuxian2); jiuxianContent.add(jiuxian3); jiuxianContent.add(jiuxian4); jiuxianContent.add(jiuxian5); document.add(jiuxianContent); document.add(blank); Date nowTime = new Date(); SimpleDateFormat matter = new SimpleDateFormat("(MM月dd日HH时mm分)"); Paragraph notice = new Paragraph("统计时间:" + matter.format(nowTime) + ",请您根据情况停车", new Font(Font.NORMAL, 12, Font.BOLD, new Color(255, 0, 0))); notice.setAlignment(0); notice.setSpacingBefore(12); document.add(notice); document.close(); |
最后就会生成一个rft文档了。
截图: