谢谢dmahapatro。我以前尝试过,但不起作用。
仅供参考,我通过在 Config.groovy 重新安排内容协商来修复它。
从改变
mime.types = [ xml: ['text/xml', 'application/xml'],
text: 'text/plain',
js: 'text/javascript',
rss: 'application/rss+xml',
atom: 'application/atom+xml',
css: 'text/css',
csv: 'text/csv',
all: '*/*',
json: 'text/json',
html: ['text/html','application/xhtml+xml']
]
至
mime.types = [
all: '*/*',
atom: 'application/atom+xml',
css: 'text/css',
csv: 'text/csv',
form: 'application/x-www-form-urlencoded',
html: ['text/html','application/xhtml+xml'],
js: 'text/javascript',
json: ['application/json', 'text/json'],
multipartForm: 'multipart/form-data',
rss: 'application/rss+xml',
text: 'text/plain',
hal: ['application/hal+json','application/hal+xml'],
xml: ['text/xml', 'application/xml']
]
解决问题。
不知道为什么顺序很重要,但我认为这是由 Grails 2.3 数据绑定打算解析请求正文并绑定到我的命令对象并导致 xml 解析器错误引起的。