私のアプリケーションには、中央コントローラクラスを拡張する多数のコントローラがあります。現在、すべてのコントローラ関数で、私の関数が現在のユーザー名を取得するために、この関数に要求を渡す必要があります。このコントローラークラスは、余分なパラメーターとして要求することなく、独自の要求を取得することは可能ですか?あなたはこのようなものを使用することができますコントローラライブラリはHttpServletRequestに直接アクセスします
public class Controller {
protected String environment;
public Controller() {
}
public ModelAndView prepareModel (HttpServletRequest request, ModelAndView model) {
contentDao.clearExpiredLocks();
model.addObject("currentUser", contentDao.findUser(request.getRemoteUser()));
//define current environment
this.environment = (request.getRequestURL().indexOf("localhost") > 0) ? "dev" : "uat";
model.addObject("environment", this.environment);
完璧な、ちょうど私が探していたもの! – Webnet