點擊按鈕,jsp頁面數(shù)據(jù)變成pdf保存到本地,用什么實現(xiàn)
iText其實JasperReport是基于iText的。于是有的人會說,那么直接使用iText不是一種倒退么?的確,直接使用iText似乎就需要直接使用原生的API進行編程了。不過幸好iText其實提供了一些方便的API,通過使用這些API,我們可以直接將HTML代碼轉(zhuǎn)化成iText可識別的Document對象,從而導(dǎo)出PDF文檔。
importjava.io.FileOutputStream;importjava.io.FileReader;importjava.util.ArrayList;importcom.lowagie.text.Document;importcom.lowagie.text.Element;importcom.lowagie.text.html.simpleparser.HTMLWorker;importcom.lowagie.text.html.simpleparser.StyleSheet;importcom.lowagie.text.pdf.PdfWriter;publicclassMainClass{publicstaticvoidmain(String[]args)throwsException{Documentdocument=newDocument();StyleSheetst=newStyleSheet();st.loadTagStyle("body","leading","16,0");PdfWriter.getInstance(document,newFileOutputStream("html2.pdf"))
;document.open()
;ArrayListp=HTMLWorker.parseToList(newFileReader("example.html"),st);for(intk=0;k<p.size();++k)document.add((Element)p.get(k));document.close();}
}這是從網(wǎng)上找到的一個例子。從代碼中,我們可以看到,iText本身提供了一個簡單的HTML的解析器,它可以把HTML轉(zhuǎn)化成我們需要的PDF的document。滿意請采納
jep后綴,格式是什么東西
JEP是Javaexpressionparser的簡稱,即java表達式分析器Jep是一個用來轉(zhuǎn)換和計算數(shù)學表達式的java庫。通過這個程序包,用戶可以以字符串的形式輸入一個、任意的公式,然后快速地計算出結(jié)果。Jep支持用戶自定義變量、常量和函數(shù)。包括許多常用的數(shù)學函數(shù)和常量。
golang本身是用什么語言寫的
golang本身是用什么語言編寫的?類似「xx語言是用什么語言實現(xiàn)的」這種疑問挺常見的,特別對于剛接觸編程語言的人!記得我剛接觸時,很困惑:這個語言是C實現(xiàn)的,那C是什么實現(xiàn)的?借此,咱們梳理下這個問題!
編程語言的發(fā)展在計算機發(fā)展初期,編程直接通過機器指令和計算機交互,也就是機器語言,一堆0101,簡直無法讀無法改,所以發(fā)展出匯編語言。匯編語言指令總體上和機器語言指令是一一對應(yīng)的,但可讀性有了很大加強!這兩種語言稱為低級語言。
20世紀50、60年代,涌現(xiàn)了各種高級語言,在70年代初,隨著Unix的開發(fā),C語言被開發(fā)出來,一直流行到現(xiàn)在。
之后編程語言不斷發(fā)展,出現(xiàn)了面向?qū)ο缶幊陶Z言、函數(shù)式編程語言,還分為動態(tài)語言和靜態(tài)語言等等。真是百花齊放百家爭鳴。
然而,編程語言的發(fā)展并沒有就此止步。在過去的十年內(nèi),又涌現(xiàn)出很多新的語言,如:Go、Swift、Rust、Kotlin、Dart等等。新語言有一些先天優(yōu)勢:沒有歷史包袱,可以吸納這么多年,其他語言的優(yōu)勢,避免一些問題,同時有些是為了解決某一些問題而出現(xiàn),也是為了解決之前語言的一些問題。因此,這些新語言,關(guān)注度都不錯。
Go語言的發(fā)展歷程2009年11月,Google對外宣布,開源其通用編程語言Go語言,因為Google出品,同時創(chuàng)作者又是特別有名的幾個人,立馬引起大家極大的興趣,當年Go奪下了TIOBE2019年年度編程語言稱號。2012年3月份,Go發(fā)布了Go1.0穩(wěn)定版本。之后每年發(fā)布兩個版本。下圖是目前為止,發(fā)布版本的情況,下表主要列舉GC相關(guān)的改進。
Go本身用什么語言實現(xiàn)Go1.4之前(包括1.4),主要是C語言實現(xiàn)的(當然還有部分匯編);Go1.5開始,實現(xiàn)了自舉:也就是用低版本的Go語言編譯自己,這個過程,Go團隊做了大量的自動化轉(zhuǎn)換工作。
所以,現(xiàn)在Go語言是用Go語言實現(xiàn)的,當然,包含部分匯編代碼。
https://github.com/golang/go
這是Go語言源碼地址。Go語言中文網(wǎng),致力于每日分享編碼知識,歡迎關(guān)注我,會有意想不到的收獲!eclipse解析wsdl文件,怎么獲取wsdl信息
一個WSDL文檔通常包含7個重要的元素,即types、import、message、portType、operation、binding、service元素。這些元素嵌套在definitions元素中,(1)Definitions是WSDL文檔的根元素。對應(yīng)于這個類:org.eclipse.wst.wsdl.Definition其他的對象都可以通過這個對象獲得(2)Types-數(shù)據(jù)類型定義的容器,它使用某種類型系統(tǒng)(一般地使用XMLSchema中的類型系統(tǒng))。(3)Message-通信消息的數(shù)據(jù)結(jié)構(gòu)的抽象類型化定義。使用Types所定義的類型來定義整個消息的數(shù)據(jù)結(jié)構(gòu)。(4)PortType-對于某個訪問入口點類型所支持的操作的抽象集合,這些操作可以由一個或多個服務(wù)訪問點來支持。(子節(jié)點)Operation-對服務(wù)中所支持的操作的抽象描述,一般單個Operation描述了一個訪問入口的請求/響應(yīng)消息對。(5)Binding-特定端口類型的具體協(xié)議和數(shù)據(jù)格式規(guī)范的綁定。(6)Service-相關(guān)服務(wù)訪問點的集合。(子節(jié)點)Port-定義為協(xié)議/數(shù)據(jù)格式綁定與具體Web訪問地址組合的單個服務(wù)訪問點。下面是代碼實例:importjava.io.File;importjava.io.IOException;importjava.util.Iterator;importjava.util.List;importjava.util.Map;importjava.util.Set;importjavax.wsdl.Message;importjavax.wsdl.Part;importjavax.wsdl.PortType;importjavax.xml.namespace.QName;importorg.eclipse.emf.common.util.URI;importorg.eclipse.emf.ecore.resource.Resource;importorg.eclipse.emf.ecore.resource.ResourceSet;importorg.eclipse.emf.ecore.resource.impl.ResourceSetImpl;importorg.eclipse.wst.wsdl.Definition;importorg.eclipse.wst.wsdl.Types;importorg.eclipse.wst.wsdl.internal.impl.PartImpl;importorg.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;importorg.eclipse.wst.wsdl.util.WSDLResourceImpl;importorg.eclipse.xsd.XSDElementDeclaration;importorg.eclipse.xsd.XSDSchema;importorg.eclipse.xsd.util.XSDResourceImpl;importorg.junit.Test;importorg.junit.Before;publicclassWSDLParserWithEclipse{ Definitiondefinition=null; StringwsdlPathString="E:/HelloEclipse-EMF-WSDL-XSD/test.wsdl"; @Before publicvoidsetup(){ ResourceSetresourceSet=newResourceSetImpl(); Resource.Factory.Registryregistry=resourceSet.getResourceFactoryRegistry(); MapextensionToFactoryMap=registry.getExtensionToFactoryMap(); extensionToFactoryMap.put("wsdl",newWSDLResourceFactoryImpl()); FilewsdlFile=newFile(wsdlPathString); URIuri=URI.createFileURI(wsdlFile.getAbsolutePath()); //Youcanavoidthiscast,butwillhavetocastanywaylatertogettheDefinitionouttheresourcecontents WSDLResourceImplwsdlResource=(WSDLResourceImpl)resourceSet.createResource(uri); try{ wsdlResource.load(null); definition=wsdlResource.getDefinition(); }catch(Exceptione){ e.printStackTrace(); } } @TestpublicvoidtestTypes(){ Typestypes=definition.getETypes(); Listschemas=types.getSchemas("http://www.xxxxx.com/problem"); XSDSchemaschema=(XSDSchema)schemas.get(0); org.eclipse.xsd.util.XSDResourceImpl.serialize(System.out,schema.getElement());}@TestpublicvoidtestMessage(){ Mapmessages=definition.getMessages(); System.out.println("Themessagesizeis:"+messages.size()); SetsetMessages=messages.keySet(); IteratoriteratorMessages=setMessages.iterator(); while(iteratorMessages.hasNext()){ QNamekey=(QName)iteratorMessages.next(); Messagemessage=(Message)messages.get(key); //{http://www.xxxxx.com/problem}getKeysSoapIn //System.out.println("MessageName:"+message.getQName()); if(message.getQName().toString().indexOf("getKeysSoapIn")>0){ System.out.println("MessageName:"+message.getQName()); MappartsMap=message.getParts(); //org.eclipse.xsd.impl.XSDElementDeclarationImpl System.out.println("MessagePartsizeforgetKeysSoapInmessageis:"+partsMap.size()); PartImplpart=(PartImpl)partsMap.get("problem"); XSDElementDeclarationxsdElementDeclaration=part.getElementDeclaration(); XSDResourceImpl.serialize(System.out,xsdElementDeclaration.getElement()); } }}@TestpublicvoidtestPortType(){ MapportTypes=definition.getPortTypes(); System.out.println("PortTypesize:"+portTypes.size()); if(portTypes!=null&&portTypes.size()>0){ Setset=portTypes.keySet(); Iteratoriterator=set.iterator(); while(iterator.hasNext()){ QNameobject=(QName)iterator.next(); PortTypeportType=(PortType)portTypes.get(object); System.out.println("PortTypename:"+portType.getQName()); org.eclipse.xsd.util.XSDResourceImpl.serialize(System.out,portType.getDocumentationElement()); } }} }