问题
当我尝试寻找替代方法时,这是对昨天(未答复)问题(见此处)的后续跟进.
我添加了基本的
<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.jsfHttpServletRequest.getRequestURI 回报 /foldername/404search.jsfHttpServletRequest.getQueryString 什么都不回报我想要它回来 /foldername/wrong-url-the-user-entered#anchor-if-there-is-any
细节...
想法是获取用户输入的URL(例如www.site.com/product/99999-product-that-cant-be-found或www.site.com/faq/support-question-that-doesnt-exist),REGEX它以删除连字符并使用99999 product that cant be found或运行搜索查询support question that doesnt exist.
有什么建议?