真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java代碼生成 java代碼生成器怎么寫

java代碼生成器怎么用

zip包,然后自動(dòng)下載下來(lái)

我們擁有十年網(wǎng)頁(yè)設(shè)計(jì)和網(wǎng)站建設(shè)經(jīng)驗(yàn),從網(wǎng)站策劃到網(wǎng)站制作,我們的網(wǎng)頁(yè)設(shè)計(jì)師為您提供的解決方案。為企業(yè)提供網(wǎng)站建設(shè)、成都做網(wǎng)站、微信開發(fā)、小程序定制開發(fā)、移動(dòng)網(wǎng)站建設(shè)、H5場(chǎng)景定制、等業(yè)務(wù)。無(wú)論您有什么樣的網(wǎng)站設(shè)計(jì)或者設(shè)計(jì)方案要求,我們都將富于創(chuàng)造性的提供專業(yè)設(shè)計(jì)服務(wù)并滿足您的需求。

1.預(yù)先定義好模板

2.界面輸入相關(guān)參數(shù)

3.解析模板生成代碼并下載

最后放出源代碼:

package com.et.controller.system.createcode;

import java.util.ArrayList;

import java.util.Date;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import com.et.controller.base.BaseController;

import com.et.util.DelAllFile;

import com.et.util.FileDownload;

import com.et.util.FileZip;

import com.et.util.Freemarker;

import com.et.util.PageData;

import com.et.util.PathUtil;

/**

* 類名稱:FreemarkerController

* 創(chuàng)建人:Harries

* 創(chuàng)建時(shí)間:2015年1月12日

* @version

*/

@Controller

@RequestMapping(value=”/createCode”)

public class CreateCodeController extends BaseController {

/**

* 生成代碼

*/

@RequestMapping(value=”/proCode”)

public void proCode(HttpServletResponse response) throws Exception{

PageData pd = new PageData();

pd = this.getPageData();

/* ============================================================================================= */

String packageName = pd.getString(“packageName”); //包名 ========1

String objectName = pd.getString(“objectName”); //類名 ========2

String tabletop = pd.getString(“tabletop”); //表前綴 ========3

tabletop = null == tabletop?””:tabletop.toUpperCase(); //表前綴轉(zhuǎn)大寫

String zindext = pd.getString(“zindex”); //屬性總數(shù)

int zindex = 0;

if(null != zindext !””.equals(zindext)){

zindex = Integer.parseInt(zindext);

}

ListString[] fieldList = new ArrayListString[](); //屬性集合 ========4

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

fieldList.add(pd.getString(“field”+i).split(“,fh,”)); //屬性放到集合里面

}

MapString,Object root = new HashMapString,Object(); //創(chuàng)建數(shù)據(jù)模型

root.put(“fieldList”, fieldList);

root.put(“packageName”, packageName); //包名

root.put(“objectName”, objectName); //類名

root.put(“objectNameLower”, objectName.toLowerCase()); //類名(全小寫)

root.put(“objectNameUpper”, objectName.toUpperCase()); //類名(全大寫)

root.put(“tabletop”, tabletop); //表前綴

root.put(“nowDate”, new Date()); //當(dāng)前日期

DelAllFile.delFolder(PathUtil.getClasspath()+”admin/ftl”); //生成代碼前,先清空之前生成的代碼

/* ============================================================================================= */

String filePath = “admin/ftl/code/”; //存放路徑

String ftlPath = “createCode”; //ftl路徑

/*生成controller*/

Freemarker.printFile(“controllerTemplate.ftl”, root, “controller/”+packageName+”/”+objectName.toLowerCase()+”/”+objectName+”Controller.java”, filePath, ftlPath);

/*生成service*/

Freemarker.printFile(“serviceTemplate.ftl”, root, “service/”+packageName+”/”+objectName.toLowerCase()+”/”+objectName+”Service.java”, filePath, ftlPath);

/*生成mybatis xml*/

Freemarker.printFile(“mapperMysqlTemplate.ftl”, root, “mybatis_mysql/”+packageName+”/”+objectName+”Mapper.xml”, filePath, ftlPath);

Freemarker.printFile(“mapperOracleTemplate.ftl”, root, “mybatis_oracle/”+packageName+”/”+objectName+”Mapper.xml”, filePath, ftlPath);

/*生成SQL腳本*/

Freemarker.printFile(“mysql_SQL_Template.ftl”, root, “mysql數(shù)據(jù)庫(kù)腳本/”+tabletop+objectName.toUpperCase()+”.sql”, filePath, ftlPath);

Freemarker.printFile(“oracle_SQL_Template.ftl”, root, “oracle數(shù)據(jù)庫(kù)腳本/”+tabletop+objectName.toUpperCase()+”.sql”, filePath, ftlPath);

/*生成jsp頁(yè)面*/

Freemarker.printFile(“jsp_list_Template.ftl”, root, “jsp/”+packageName+”/”+objectName.toLowerCase()+”/”+objectName.toLowerCase()+”_list.jsp”, filePath, ftlPath);

Freemarker.printFile(“jsp_edit_Template.ftl”, root, “jsp/”+packageName+”/”+objectName.toLowerCase()+”/”+objectName.toLowerCase()+”_edit.jsp”, filePath, ftlPath);

/*生成說(shuō)明文檔*/

Freemarker.printFile(“docTemplate.ftl”, root, “說(shuō)明.doc”, filePath, ftlPath);

//this.print(“oracle_SQL_Template.ftl”, root); 控制臺(tái)打印

/*生成的全部代碼壓縮成zip文件*/

FileZip.zip(PathUtil.getClasspath()+”admin/ftl/code”, PathUtil.getClasspath()+”admin/ftl/code.zip”);

/*下載代碼*/

FileDownload.fileDownload(response, PathUtil.getClasspath()+”admin/ftl/code.zip”, “code.zip”);

}

}

java代碼生成dat文件

File?filename?=?new?File("F:\\zd.dat");

說(shuō)明:dat可以改成任何擴(kuò)展名,是自己可以定義的,如下:

public?void?createFile(){

//path表示所創(chuàng)建文件的路徑

String?path?=?"d:/tr/rt";

File?f?=?new?File(path);

if(!f.exists()){

f.mkdirs();

}?

//?fileName表示創(chuàng)建的文件名;為txt類型;

String?fileName="test.txt";

File?file?=?new?File(f,fileName);

if(!file.exists()){

try?{

file.createNewFile();

}?catch?(IOException?e)?{

//?TODO?Auto-generated?catch?block

e.printStackTrace();

}

}

}

//現(xiàn)在可以在d:/tr/rt?目錄下找到test.txt文件

請(qǐng)問(wèn)java代碼可不可以生成exe文件

分類: 電腦/網(wǎng)絡(luò) 程序設(shè)計(jì) 其他編程語(yǔ)言

問(wèn)題描述:

我是剛剛學(xué)Java,請(qǐng)問(wèn)java代碼可不可以生成exe文件,我用的是JCreator

解析:

可以,用JBuilder 自帶的工具可以轉(zhuǎn)換成exe文件

不過(guò)所謂的exe可執(zhí)行文件,執(zhí)行的前提是必須機(jī)器上面安裝了JVM(java虛擬機(jī)),就是說(shuō),不是任何一臺(tái)機(jī)器都能跑java做的exe

換句話來(lái)說(shuō),JAVA是調(diào)用底層的C包,必須經(jīng)過(guò)虛擬機(jī)的編譯。也正是如此,JAVA具有跨平臺(tái)性,換個(gè)角度來(lái)看,它的優(yōu)勢(shì)也是它的劣勢(shì)

如何用Java代碼段生成四位數(shù)字加字母的驗(yàn)證碼?

不知道你問(wèn)的是不是生成這種圖片驗(yàn)證碼?如果只要一個(gè)隨機(jī)四位數(shù) 那這行代碼就夠了(new Random().nextInt(9000) + 1000;),如果是生成頁(yè)面圖片驗(yàn)證碼就是下面的了: //設(shè)定 響應(yīng)模式 resp.setContentType("image/jpeg"); // 生成令牌環(huán)數(shù)據(jù); Integer token = new Random().nextInt(9000) + 1000; // 保存令牌環(huán)數(shù)據(jù)到session中 req.getSession().setAttribute(IMAGE_TOKEN_NAME, token); // 生成令牌環(huán)圖片 ServletOutputStream out = resp.getOutputStream(); BufferedImage img = new BufferedImage(60, 20, BufferedImage.TYPE_INT_RGB); Graphics g = img.getGraphics(); g.setColor(Color.YELLOW); g.fillRect(0, 0, img.getWidth(), img.getHeight()); g.setColor(Color.BLUE); g.setFont(new Font("", Font.BOLD, 18)); g.drawString(String.valueOf(token), 10, 16); ImageIO.write(img, "jpg", out); out.close();

下面簡(jiǎn)單的介紹他們的功能和用途,執(zhí)行效率等。每個(gè)都有各自的優(yōu)缺點(diǎn)看你是做甚什么方面的研究開發(fā)用。點(diǎn)虐 ,是網(wǎng)站編程,現(xiàn)在很多都用這個(gè),但是這個(gè)語(yǔ)言編程都有統(tǒng)一思路,很好掌握。窒息那個(gè)效率不是很高;php 支持跨平臺(tái),很容易學(xué)會(huì),執(zhí)行的效率很高;asp是ASP點(diǎn)虐 的前身,它比較穩(wěn)定,比點(diǎn)虐 要弱一點(diǎn)。但是比點(diǎn)虐 好學(xué)。jsp 是網(wǎng)頁(yè)編程,這個(gè)學(xué)習(xí)大約一周就能搞定,不過(guò)這個(gè)得多實(shí)踐,不然的話,時(shí)間長(zhǎng)了,就容易忘記。

我自己做的系統(tǒng)里面用作驗(yàn)證碼的JSP的%@page contentType="image/jpeg;charset=utf-8"%%@page import="java.util.*,java.awt.*,java.awt.image.*,javax.imageio.*" %%@ page import="java.io.OutputStream" %html body %! Color getRandColor(int fc,int bc) { Random rd=new Random(); if(fc255) fc=255; if(bc255) bc=255; int red=fc+rd.nextInt(bc-fc); int green=fc+rd.nextInt(bc-fc); int blue=fc+rd.nextInt(bc-fc); return new Color(red,green,blue); } % % Random r=new Random(); response.addHeader("Pragma","No-cache"); response.addHeader("Cache-Control","no-cache"); response.addDateHeader("expires",0); int width=90; int height=23; BufferedImage pic=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB); Graphics gc=pic.getGraphics(); gc.setColor(getRandColor(200,250)); gc.fillRect(0,0,width,height); String[] rNum ={"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f", "g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w", "x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N", "O","P","Q","R","S","T","U","V","W","X","Y","Z"}; int[] style = {Font.PLAIN,Font.BOLD,Font.ITALIC,Font.PLAIN+Font.BOLD, Font.BOLD+Font.ITALIC,Font.PLAIN+Font.ITALIC,Font.PLAIN+Font.BOLD+Font.ITALIC}; gc.setColor(Color.WHITE); gc.drawLine(0,30,90,10); gc.setColor(getRandColor(160,200)); for (int i=0;i50;i++) { int x = r.nextInt(width); int y = r.nextInt(height); int xl = r.nextInt(10); int yl = r.nextInt(10); gc.drawLine(x,y,x+xl,y+yl); } gc.setColor(getRandColor(60,150)); String rt = ""; for(int i=0;i4;i++){ String temp = rNum[r.nextInt(62)]; rt = rt+temp; gc.setFont(new Font("Times New Roman",style[r.nextInt(7)],15)); gc.drawString(temp,5+i*15+r.nextInt(10),10+r.nextInt(10)); } gc.dispose(); session.setAttribute("randNum",rt); OutputStream os=response.getOutputStream(); ImageIO.write(pic,"JPEG",os); System.out.println("當(dāng)前驗(yàn)證碼為:"+session.getAttribute("randNum")); os.flush(); os.close(); os=null; response.flushBuffer(); out.clear(); out = pageContext.pushBody(); % /body/html


新聞名稱:java代碼生成 java代碼生成器怎么寫
文章鏈接:http://weahome.cn/article/ddsodij.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部