Skip to main content

Obtaining the Request Interface

Because the lifecycle of a request is special, it cannot be injected normally through @Inject. Hasor provides a convenient way to obtain it:

@MappingTo("/helloAction.do")
public class HelloAction {
@Any
public void execute(HttpServletRequest request) {
...
}
}

Types that can be injected into methods include:

InterfaceDescription
javax.servlet.ServletRequestServletRequest
javax.servlet.http.HttpServletRequestHttpServletRequest
javax.servlet.ServletResponseServletResponse
javax.servlet.http.HttpServletResponseHttpServletResponse
javax.servlet.http.HttpSessionHttpSession
javax.servlet.ServletContextServletContext
net.hasor.web.Invoker or a custom subtypeRepresents one request invocation
net.hasor.web.render.RenderInvokerInvoker extension for page rendering
net.hasor.web.valid.ValidInvokerInvoker extension for form validation
net.hasor.core.AppContextContainer interface
net.hasor.cobble.setting.SettingsConfiguration-related interface