在struts应用程序中,我有一个过滤器,强制某些页面只能通过重定向访问https.我正在考虑移植它,所以我的问题是:在这种环境中,是否有一种"提升"方式来实现这样的过滤器,或者它与struts中的相似/相同?谢谢
Dav*_*lak 11
在Lift中,SiteMap定义了页面访问的规则.您可以创建一个SiteMap条目,在某些页面上重定向到https站点:
// create an object that does a redirect to the https server if the
// request is on http
object RequireSSL extends Loc.EarlyResponse(
() => {
for {
r <- S.request
lowLevelReq <- Box !! r if lowLevelReq.scheme == "http"
} {
S.redirectTo("https://"+lowLevelReq.serverName+lowLevelReq.contextPath)
}
Empty
})
// Build SiteMap
def entries = (Menu("Home") / "index") ::
(Menu("Secure") / "secure" >> RequireSSL) ::
Nil
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.