Stop Grails from reading my request

僤鯓⒐⒋嵵緔 提交于 2019-12-25 15:31:29

问题


I want to create a URL in my Grails application where I want to handle things before Grails read the request body. Specifically, I want to read a file stream and handle it myself before Grails reads it. To do this, I created a custom servlet and mapped it from web.xml by following this -

grails install-templates

Then, created the servlet as src/java/MyServlet.java and then added following to web.xml

<servlet>
    <servlet-name>uploader</servlet-name>
    <servlet-class>MyServlet</servlet-class>        
</servlet>

<servlet-mapping>
    <servlet-name>uploader</servlet-name>
    <url-pattern>/upload/execute</url-pattern>
</servlet-mapping>

However, Grails is still reading my request before it reaches my servlet. I suspect this because I am not getting any request body in MyServlet


回答1:


Grails has a builtin option to disable processing of Multipart request. Just toggle following setting to true in Config.groovy -

grails.web.disable.multipart=true


来源:https://stackoverflow.com/questions/46892481/stop-grails-from-reading-my-request

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!