简体   繁体   中英

How to get HttpServletRequest and HttpServletResponse in FreeMarker?

I just took over a freemarker project. The controller classes extend the abstract class squirrel.web.SquProcessor, and use squirrel.web.PageData to transfer values. But now, I want to use the HttpServletRequest and HttpServletResponse in the controller classes. How to get them?

FreeMarker is unaware of servlets or HTTP (barring the included FreemarkerServlet that was added to ease migrating from JSP). You see in templates what the controller class has exposed to FreeMarker. Exposing highly technical things like servlet request/response object is not very clean; ideally the template should only get application-domain objects and some helpers to generate URL-s and such.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM