开发者

How to map a dynamic profile number to a servlet?

How could I map a dynamic profile number to a servlet for example

 http://stackoverflow.com/questions/2585407

I want to map this 2585407 to a servlet is this possible?

T开发者_Python百科hanks


Yes, and there are multiple options:

  • use an UrlRewriteFilter to rewrite the given url to questions?id=2585407, then read the request parameter
  • use some framework like Spring-MVC that supports beatiful URLs
  • map the servlet to /questions/* (in web.xml) and then parse the getRequestURI() (by stripping the prefix and the request.getContextPath())


use following pattern in URL mapping

/questions/*


If your <url-mapping> is set to

/questions/*

Then you would get your question id by using request.getPathInfo() (request being HttpServletRequest).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜