How to use multipart/form-data encoding in application running on GlassFish 3.1.1

余生颓废 提交于 2019-12-13 18:16:16

问题


I have a JSF 2.0 application running under GlassFish 3.1.1, and I wish to use the new FileUpload component in PrimeFaces 3.0.1, which requires that form data be encoded as multipart/form-data, as in:

<h:form id="quoteform" enctype="multipart/form-data">

However, as soon as I add the above enctype attribute to my form, it no longer works - the bean methods tied to my submit and cancel buttons are never invoked.

I did find a reference to an issue with Mojarra (part of GlassFish I believe) and multipart/form-data encoding, but it's almost two years old - certainly it must have been addressed by now I figure. Is there something else I need to do to use this type of encoding under GlassFish, or something that needs to be updated? And if there is a known issue remaining, what is the culprit?


回答1:


There is a regression in the current Glassfish 3.1.2 b23, that was introduced as a fix to some previous bug, so I think its still valid.

Details of the probable cause are below and in the glassfish issue ticket http://java.net/jira/browse/GLASSFISH-18444 but it can be summarised by this other gf 3.1.2 user comment "I'm currently experiencing this with the Magnolia CMS (http://www.magnolia-cms.com/) where every single form stopped working in glassfish 3.1.2 with the following exception..."

I deployed a 3.1 version locally of glassfish and I have tested that the readLine() problem is not there with form multipart, so would suggest reverting to the 3.1 archived version of glassfish instead of 3.1.2 b23.

http://java.net/jira/browse/GLASSFISH-18444
"In glassfish 3.1 this used to work and print out the form data (the content of the InputStream could still be used after calling getParameter()). This has changed in glassfish 3.1.2 probably because of the changes for GLASSFISH-16740.

These changes will cause major problems in web applications that use multipart formdata, but do not yet use the getParts() method to retrieve the data, but some proprietary method. Any call to getParameter() before the files are parsed will cause the parsing of the multipart formdata to fail. I'm currently experiencing this with the Magnolia CMS (http://www.magnolia-cms.com/) where every single form stopped working in glassfish 3.1.2 with the following exception:"

it seems that the issue is related to these open issues on the deployed GLASSFISH 3.1.2;

http://java.net/jira/browse/GLASSFISH-18453
http://java.net/jira/browse/GLASSFISH-18444
http://java.net/jira/browse/GLASSFISH-16740

"Incompatible breaking changes to getParameter() / getPart()" Affects Version/s: 3.1.2_b23

So this is affecting any forms in the site that have file upload multipart form components. I can replicate this problem locally on a glassfish 3.1.2_b23.



来源:https://stackoverflow.com/questions/9074615/how-to-use-multipart-form-data-encoding-in-application-running-on-glassfish-3-1

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