问题
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