URLRewrite 过滤器不适用于多部分表单
我正在使用 tuckey URLRewrite 过滤器,其规则之一如下:
<rule>
<name> Proxy URL with jession ID's </name>
<note>
</note>
<condition type="parameter" name="ParamName">[\p{ASCII}]+</condition>
<from>^/([^?]*)\.htm(.*)$</from>
<to type="proxy">%{request-url};jsessionid=%{parameter:ParamName}$2</to>
</rule>
一旦我将 enctype="multipart/form-data"
添加到我的表单(顺便说一句,它使用 POST 方法),问题就会出现。过滤器无法重写 url。
有什么想法如何解决这个问题吗?
I am using tuckey URLRewrite filter having one of its rules as follows:
<rule>
<name> Proxy URL with jession ID's </name>
<note>
</note>
<condition type="parameter" name="ParamName">[\p{ASCII}]+</condition>
<from>^/([^?]*)\.htm(.*)lt;/from>
<to type="proxy">%{request-url};jsessionid=%{parameter:ParamName}$2</to>
</rule>
The problem arises as soon as I add enctype="multipart/form-data"
to my form (which uses POST method btw). The filter is unable to rewrite url.
Any ideas how to solve this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您可以更改应用程序的源,则可以对其进行修改,以便可以使用提取 JSESSIONID 的“参数”方法。默认情况下(至少在 Tomcat 上),JSESSIONID 不会在表单发布中传递,但您可以修改表单以包含它。例如,JSP 页面可能如下所示:
或者,您可以尝试使用不同的条件从会话 cookie 中获取 JSESSIONID。我还没有尝试过以下方法,但想象类似的方法可能对您有用:
您还可以使用其他条件来检查会话 ID 是否有效(requested-session-id-valid)、起源来自 cookie (requested-session-id-from-cookie) 或源自 post 操作的 URL (requested-session-id-from-url)。
我不确定您使用的是哪个版本的 UrlRewriteFilter,但如果您查看以下 URL 中的“永久重定向包含 jsessionid 的传入 URL。”示例,您将看到 JSESSIONID 不是类似参数其他 POST/GET 参数是。
http://urlrewritefilter.googlecode.com/svn/trunk /src/doc/manual/3.2/guide.html
我强烈建议您同时使用 Firefox/Firebug 来检查您的 POST 请求和标头,以便您准确了解正在传递的内容。 (我确信还有其他类似的工具也可以做到这一点,Fiddler 2 等)。
If you can change the source of the application you could modify it so that you can use the "parameter" method of extracting the JSESSIONID. By default (at least on Tomcat) the JSESSIONID will not be passed in the form post but you could modify your form to include it. For example a JSP page might look like this:
Alternatively you could try and fetch the JSESSIONID from the session cookie using a different condition. I have not tried the following but imagine something like it could work for you:
There are other conditions you could potentially use to check whether the session id was valid (requested-session-id-valid), originated from a cookie (requested-session-id-from-cookie) or originated from the URL of the post action (requested-session-id-from-url).
I'm not sure which version of UrlRewriteFilter you are using but if you look at the "Permanently redirect incoming URLs containing jsessionid." example at the following URL you will see that the JSESSIONID is not a parameter like other POST/GET parameters are.
http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/3.2/guide.html
I can highly recommend using the Firefox/Firebug together to examine your POST request and headers so you get an idea for exactly what is being passed. (I'm sure there are other similar tools that do this too, Fiddler 2 etc.).