问题
I am using SWFUpload to upload files to java servlet (spring framework). The problem is that the current web session is lost during file upload (it creates a new session). I read that it is a known bug and there are some workarounds somewhere but I can't find anything. Does anyone know how to make it work?
Thanks.
回答1:
Have a look at this post on the SWFUpload forums. Adding ;jsessionid=XXX
to the upload URL may work for you, or it may not; the exact cause of the problem appears unclear. Note that Flash uses the Wininet stack (same as IE), so if you are using a different browser you need to somehow get the session cookie (known to your browser) into the IE cookie.
回答2:
Had this on the .NET platform as well. The problem is that the Flash Object runs in a different session context than your Java App (it's effectively treated like a new client). One way to get around all of this is to effectively have the object post any necessary information needed to commit the uploads back in the querystring.
回答3:
The known bug you describe sounds like this one. If you have the time please sign up just to say "I have this problem too" so we can make it really clear to Adobe that it is affecting a lot of people.
It is hard to give an example of the best way to do it for your particular situation as I don't know much about spring.
That said, the usual way to work around it is to append a GET variable with the session to the upload url, then take that and manually set it to be the session on the server-side.
Here's another SO thread about this problem that has a good answer (unfortunately not specific to java+spring, but might give you a better idea).
Hopefully that's enough detail to get you off to a good start.
来源:https://stackoverflow.com/questions/1155113/swfupload-and-java-session-is-lost