UrlRewriteFilter run元素产生404,但元素在GAE / Java上工作正常 [英] UrlRewriteFilter run element produces 404 but to element works fine on GAE/Java

查看:118
本文介绍了UrlRewriteFilter run元素产生404,但元素在GAE / Java上工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用UrlRewriteFilter库来避免编写自己的url过滤器。



我很确定我已经正确设置了一些东西,因为当我在我的url中有这个重写xml时:

 < rule> 
< from> ^ / urlIWantToMap< / from>
< to type =redirect> / WhereIWouldLikeItToGo< / to>
< / rule>

它似乎正常工作(如在 http:// localhost:8080 / urlIWantToMap 将我发送到预定位置)。请注意,我必须将servlet映射添加到我的web.xml中。



如果我试试这个,虽然...

 < rule> 
< from> ^ / urlIWantToMap< / from>
< run class =mypackage.MyServletClassmethod =doGet/>
< / rule>

我得到一个http 404.我认为这是这里描述的同一种问题(即使我对作者所提供的解决方案/解决方案感到怀疑):
$ b

http://greatwebguy.com/programming/java/urlrewritefilter-servlet-filter-problem-in-websphere-6105-and-greater /



如果对Web过滤器行为进行某种更改会阻止UrlRewriteFilter调用servlet,我可以看到发生这种情况。要么;或者我犯了一个明显的错误,我没有看到。

解决方案

当应用程序服务器启动时, ?

  INFO:org.tuckey.web.filters.urlrewrite.Run错误:在mypackage上找不到名为doGet的方法.MyServletClass 

即使您不这样做, public 方法doGet没有任何参数存在?在我的情况下,它受到保护,而当 http:// localhost:8080 / MyProject / rewrite-status 告诉我everthing是好的,我仍然有一个404。



我不得不创建一个封装方法来公开doGet并像这样配置urlrewrite.xml:

 < run class =my.wrappers.WrapperServletmethod =doGet(HttpServletRequest,HttpServletResponse)/> 


I'm using the UrlRewriteFilter library in order to avoid having to write my own url filter.

I'm pretty sure that I have things set up properly, because when I have this in my url rewrite xml:

    <rule>
      <from>^/urlIWantToMap</from>
      <to type="redirect">/WhereIWouldLikeItToGo</to>
    </rule>

It seems to work fine (as in, hitting http://localhost:8080/urlIWantToMap sends me to the intended location). Note that I had to add the servlet mapping to my web.xml.

If I try this though...

    <rule>
      <from>^/urlIWantToMap</from>
      <run class="mypackage.MyServletClass" method="doGet"/>
    </rule>

I get an http 404. I think it is the same kind of problem described here (even though I'm suspicious on the solution/resolution the author comes to):

http://greatwebguy.com/programming/java/urlrewritefilter-servlet-filter-problem-in-websphere-6105-and-greater/

I can see this happening if there were some kind of change to web filter behavior that would inhibit UrlRewriteFilter from calling into the servlet. Either that; or I'm making a blatant mistake I'm not seeing.

解决方案

Do you see something like this when the application server starts?

INFO: org.tuckey.web.filters.urlrewrite.Run ERROR: could not find method with the name doGet on mypackage.MyServletClass

Even if you don't, does a public method doGet exist without any parameters? In my case it was protected, and while http://localhost:8080/MyProject/rewrite-status told me everthing was fine, I still got a 404.

I had to create a wrapper method to make doGet public and configure urlrewrite.xml like this:

<run class="my.wrappers.WrapperServlet" method="doGet(HttpServletRequest, HttpServletResponse)" />

这篇关于UrlRewriteFilter run元素产生404,但元素在GAE / Java上工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆