質問

I create my contexts by dropping [myname].xml files in the contexts/ directory but in my CFML code I want to dynamically find the value of [myname], ie the name of the context/webapp (or failing that the filename of the xml file or the original value of the resourceBase property before path translation occurs).

I can get data about the context (like the array of virtualhosts) using the object returned from getPageContext().getConfig().getServletContext().getContextHandler().getCurrentWebAppContext() but if the context name is in there I haven't worked out how to get at it.

役に立ちましたか?

解決

Use getDisplayName on that object you have?

It defaults to null (would be useful if it was the filename), but you can specify it in the context XML file with <Set name="DisplayName">bob</Set>

(If you have lots of XML files to deal with, do a script to loop through each file and plonk that with the filename inside the Configure tag.)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top