I am trying to use JSoup with ColdFusion to clear some HTML, but I see the following error:
AddTags method not found. Either there are no methods with the specified method name and argument types, or the addTags method is overloaded with argument types that ColdFusion cannot reliably decrypt. ColdFusion found 0 methods that match the arguments provided. If it is a Java object and you have confirmed that the method exists, use the javacast function to reduce ambiguity.
My code is as follows:
<cfset jsoup = createObject('java','org.jsoup.Jsoup')> <cfset Whitelist = createObject("java", "org.jsoup.safety.Whitelist")> <cfset parsedhtml = jsoup.parse(form.contentrichtext)> <cfset post = parsedhtml.body().html()> <cfset post = jsoup.clean(post, Whitelist.none().addTags("span"))>
I reset the Whitelist object and the add label method is added. If I remove the addTags () method and use one of JSoup's standard whitelists, such as basic (), none () or relaxed (), then the code works fine. As far as I can see from other online examples, this is the correct syntax for using the addTags () method.
I'm new to using Java objects in ColdFusion, so it puzzled me.
Any help would be greatly appreciated.
Thanks Michael.
source share