如何使用Grails WebXmlConfig插件向WEB.XML文件添加属性?

时间:2013-06-02 00:57:48

标签: grails web.xml grails-plugin grails-2.0

我正在使用Grails的WebXmlConfig Plugin。我使用插件的1.4.1版。我做了:

grails create-web-xml-config

生成grails-app / conf / WebXmlConfig.groovy文件。当我尝试添加一个简单的属性时:

sessionConfig.sessionTimeout = 30

我收到以下错误:

 java.lang.IllegalArgumentException: <session-config> element is limited to 1 occurrence
at org.apache.catalina.startup.SetSessionConfig.begin(WebRuleSet.java:769)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1276)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537)
at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.java:1890)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1259)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)

当我执行grails install-templates并从生成的web.xml文件中删除会话超时时,它会起作用。如何在不修改原始web.xml的情况下配置WebXmlConfig.groovy?

1 个答案:

答案 0 :(得分:3)

为什么不直接使用 grails install-templates 并修改默认的web.xml文件?