如何在 ColdFusion 8 中调用 java 方法并向其传递 Coldfusion Session 变量?
我正在尝试将下面的 java 方法调用到 CFM 页面,但我似乎无法获取它。此外,我需要设置 CF 会话变量的值。
Provider.sendResponse(getServletContext(), 响应, IntegrationIDs.AuthnContextClasses.name, 用户名, 属性);
预先感谢您提供的任何帮助。
这是我的代码示例,
<cfset Obj = createobject("java","com.blah.blah.blah.Provider")/>
<cfset servletContext = />
<cfset response = />
<cfset serverName = SESSION.server/>
<cfset authnContext = />
<cfset uid = SESSION.uid />
<cfset attributes = />
<cfset targetUrl = http://yyy.com/>
<cfset Obj_value = Obj.sendResponse(
javax.servlet.ServletContext servletContext,
javax.servlet.http.HttpServletResponse response,
java.lang.String ServerName,
java.lang.String authnContext,
java.lang.String uid,
java.util.Map<java.lang.String,java.util.List<java.lang.String>>attributes,
java.lang.String targetUrl)/>
我是否以错误的方式处理这个问题。预先感谢您提供的任何帮助。非常欣赏。
I am trying to invoke the java method below to a CFM page and I can not seem to get it. Additionally I need to set the values from CF session variables.
Provider.sendResponse(getServletContext(), response, IntegrationIDs.AuthnContextClasses.name, userName, attributes);
Thank you in advance for any assistance.
Here is my code example
<cfset Obj = createobject("java","com.blah.blah.blah.Provider")/>
<cfset servletContext = />
<cfset response = />
<cfset serverName = SESSION.server/>
<cfset authnContext = />
<cfset uid = SESSION.uid />
<cfset attributes = />
<cfset targetUrl = http://yyy.com/>
<cfset Obj_value = Obj.sendResponse(
javax.servlet.ServletContext servletContext,
javax.servlet.http.HttpServletResponse response,
java.lang.String ServerName,
java.lang.String authnContext,
java.lang.String uid,
java.util.Map<java.lang.String,java.util.List<java.lang.String>>attributes,
java.lang.String targetUrl)/>
Am I approaching this the wrong way. Thank you in advance for any assistance. Greatly appreciate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的示例未显示对象的实际调用。我应该看到类似 createobject("java","com.blah.blah.blah.classname").init() 的东西,后面跟着要传递的变量的“setup”...比如“Repsonse=session.somevariabl”...您给出的示例太不完整,无法准确说明您遇到的困难。
要访问会话变量,请使用“session.XXX”。会话就像一个哈希表或向量(CF 术语中的“结构”)。如果“username”存储在会话中,则上面的示例可能类似于
Provider.sendResponse(getServletContext(), response, IntegrationIDs.AuthnContextClasses.name, session.Username, attribute );
但是如果没有更多的示例代码,我不确定您需要解决什么问题:)
Your example doesn't show the actual invoking of the object. I should see something like createobject("java","com.blah.blah.blah.classname").init() followed by "setup" of varialbes to pass ... like "Repsonse=session.somevariabl" ... the example you give is too incomplete to tell exactly where you are stumped.
To access a session variable you use "session.XXX". Session is like a hash table or vector (a "structure" in CF lingo). if "username" was stored in the session your example above could look like
Provider.sendResponse(getServletContext(), response, IntegrationIDs.AuthnContextClasses.name, session.Username, attributes);
But with out a bit more example code to go on I'm not sure what problem you need to solve :)
您不需要在调用中定义参数类型。您将调用方法与定义方法混淆了。
You do not need to define the parameter types in your call. You are confusing calling a method with defining one.