小编tsc*_*tsc的帖子

自定义错误页面 - 获取最初请求的URL

问题

当我尝试寻找替代方法时,这是对昨天(未答复)问题(见此处)的后续跟进.

我添加了基本的

    <error-page>  
            <error-code>404</error-code>  
            <location>/404search.jsf</location>  
    </error-page>
Run Code Online (Sandbox Code Playgroud)

..到我的web.xml.我现在需要获取用户输入的URL以提交给我的搜索功能,但我只设法获取当前URL(在这种情况下,... 404search.jsf)而不是用户输入的实际查询.

尝试

  • HttpServletRequest.getRequestURL 回报 http://www.website.com/foldername/404search.jsf
  • HttpServletRequest.getRequestURI 回报 /foldername/404search.jsf
  • HttpServletRequest.getQueryString 什么都不回报

我想要它回来 /foldername/wrong-url-the-user-entered#anchor-if-there-is-any

细节...

想法是获取用户输入的URL(例如www.site.com/product/99999-product-that-cant-be-foundwww.site.com/faq/support-question-that-doesnt-exist),REGEX它以删除连字符并使用99999 product that cant be found或运行搜索查询support question that doesnt exist.

有什么建议?

jsf servlets http-status-code-404

5
推荐指数
1
解决办法
1339
查看次数

标签 统计

http-status-code-404 ×1

jsf ×1

servlets ×1