开发者

How to map a dynamic profile number to a servlet?

开发者 https://www.devze.com 2023-02-28 09:56 出处:网络
How could I map a dynamic profile number to a servlet for example http://stackoverflow.com/questions/2585407

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

精彩评论

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