I’m trying to add a mime-mapping element to the web.xml.
My current best stab is:
def doWithWebDescriptor = { xml -> xml + { 'mime-mapping' { 'extension'('htc') 'mime-type'('text/x-component') } } }
I know the code is being run as the above actually outputs an invalid web.xml. The following seems to be more logical but it doesn’t actually have any effect:
def doWithWebDescriptor = { xml -> xml.'mime-mapping' + { 'extension'('htc') 'mime-type'('text/x-component') } }
edit: I’m using grails 1.0.3
Try
(note the
leftShiftinstead of theplus).Alternatively, if you want to ensure that your new element is inserted at a specific position within the XML, you can get the child element, after which you want your element to be inserted, and add yours with the
plusoperator. For example, I use the following code to add a new servlet-mapping:If you want to dig further into this, have a look at
groovy.util.slurpersupport.NodeChild(thexmlargument is of that type) and its superclassgroovy.util.slurpersupport.GPathResult.Good luck!