gpt4 book ai didi

java - 使用 ColdFusion 访问 Jar 文件类和方法

转载 作者:太空宇宙 更新时间:2023-11-04 13:29:27 27 4
gpt4 key购买 nike

我有一个 jar 文件,解压后具有以下路径

 xmlcreator.jar

xmlcreator (folder)
xmlpackage (folder)
data1.class
xxxx.class
createxml (method)

如果我像下面这样创建myObj1,我可以查看data1中的所有字段,并且field1包含value1。

 <cfset myObj1 = createObject("java","xmlpackage.data1") />
<cfset myObj1.field1 = "value1">
<cfdump var="#myObj1#">

我想在填充 data1 类中的所有字段后创建 xml。 xxxx.class 具有创建 xml 文件的 createxml 方法,但是如果我尝试以下操作,createxml 似乎不知道 data1。

 <cfset myObj2 = createObject("java","xmlpackage.xxxx”) />
<cfset myObj2.data1 = myobj1 />
<cfset return = myObj2.createxml()>

ColdFusion 错误仅在错误顶部返回 data1,没有任何解释。因此,通过创建对象 xmlpackage.xxxx 我似乎无法访问 data1。

我应该将数据放入 data1 类并获取 xxxx.createxml 来创建 xml 文件吗?

更新:

抱歉造成困惑。我认为保持简单会很容易。我已经按照我尝试执行的操作的顺序添加了代码、对象转储和错误的堆栈跟踪。

<cfset myObj = createObject("java","CDAPackage.PatientRole") />
<cfset myObj.patientFamilyName = "Jones">
<cfdump var="#myObj#">

<cfset ccdaObj = createObject("java","CDAPackage.CCDA") />
<cfdump var="#ccdaObj#">
<cfset ccdaObj.PatientRole = myobj />
<cfset x = ccdaObj.GenerateCCDA()>
<cfdump var="#x#">

myObj 转储

object of CDAPackage.PatientRole
Class Name CDAPackage.PatientRole
Methods
Method Return Type
getRaceList() java.util.List
setRaceList(java.util.List) void
Fields
Field Value
java.util.List RaceList [undefined value]
java.lang.String administrativeGenderCode [undefined value]
java.lang.String administrativeGenderDisplayName [undefined value]
CDAPackage.Address birthPlaceAddress CDAPackage.Address
java.lang.String birthTime [undefined value]
java.lang.String ethnicGroupCode [undefined value]
java.lang.String ethnicGroupCodeDisplayName [undefined value]
java.lang.String insuranceProvider [undefined value]
java.lang.String languageCommunication [undefined value]
java.lang.String languageCommunicationDisplayname [undefined value]
java.lang.String languageCommunicationModeCodeCode [undefined value]
java.lang.String languageCommunicationModeCodeDisplayName [undefined value]
java.lang.String languageCommunicationPreferenceInd [undefined value]
java.lang.String maritalStatusCode [undefined value]
java.lang.String maritalStatusDisplayName [undefined value]
java.lang.String mrn [undefined value]
CDAPackage.Address patientAddress CDAPackage.Address
java.lang.String patientFamilyName Jones
... more fields

ccdaObj 转储

object of CDAPackage.CCDA
Class Name CDAPackage.CCDA
Methods
Method Return Type
GenerateCCDA() java.lang.String
Fields
Field Value
java.lang.String CCDACode [undefined value]
java.lang.String CCDADisplayName [undefined value]
java.lang.String CCDAEffectiveTimeValue [undefined value]
java.lang.String Chiefcomplaint [undefined value]
java.lang.String DocumentID [undefined value]
java.lang.String EHRID [undefined value]
java.lang.String EHRName [undefined value]
CDAPackage.Address FacilityAddressObj CDAPackage.Address
java.util.List FunctionalStatusListObj java.util.List
CDAPackage.AssignedPerson PrimaryProviderObj CDAPackage.AssignedPerson
java.util.List ReferralListObj java.util.List
java.util.List allergyListObj java.util.List
java.util.List carePlanListObj java.util.List
java.util.List careTeamObj java.util.List
java.lang.String dischargeinstructions [undefined value]
java.util.List encounterDiagnosisListObj java.util.List
java.util.List encounterListObj java.util.List
java.util.List immunizationListObj java.util.List
java.util.List instructionListObj [undefined value]
java.util.List medicationAdministedListObj java.util.List
java.util.List medicationListObj java.util.List
CDAPackage.PatientRole patientRoleObj CDAPackage.PatientRole
... more fields

堆栈跟踪

 java.lang.NoSuchFieldException: PATIENTROLE
at coldfusion.runtime.StructBean.bindName(StructBean.java:243)
at coldfusion.runtime.Scope.put(Scope.java:74)
at coldfusion.runtime.CfJspPage._arrayset(CfJspPage.java:1093)
at coldfusion.runtime.NeoPageContext.SymTab_setSplitNameInMap(NeoPageContext.java:1429)
at coldfusion.runtime.CfJspPage._structSetAt(CfJspPage.java:2356)
at cfdllcall2ecfm1400054296.runPage(/Applications/ColdFusion11/cfusion/wwwroot/test/dllcall.cfm:16)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:246)
at ...

最佳答案

(来自评论)

java.lang.NoSuchFieldException: PATIENTROLE

查看转储中的字段,您尝试设置的字段似乎被命名为 patentRoleObj,而不是 patentRole。尝试改用该字段名称:

<cfset yourOtherObject.patientRoleObj = yourPatientRoleObject />

关于java - 使用 ColdFusion 访问 Jar 文件类和方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32332163/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com