public final class SafeDispatcherServlet extends HttpServlet { private static final long serialVersionUID = 1L; public static final String CAUGHT_THROWABLE_KEY = "exceptionCaughtByServlet"; private static final Logger LOGGER = LoggerFactory.getLogger(SafeDispatcherServlet.class); private DispatcherServlet delegate = new DispatcherServlet(); private boolean initSuccess = true; public SafeDispatcherServlet() { } public void init(ServletConfig config) { try { this.delegate.init(config); } catch (Throwable var5) { this.initSuccess = false; String message = "SafeDispatcherServlet: \nThe Spring DispatcherServlet we wrap threw on init.\nBut for our having caught this error, the servlet would not have initialized."; LOGGER.error("SafeDispatcherServlet: \nThe Spring DispatcherServlet we wrap threw on init.\nBut for our having caught this error, the servlet would not have initialized.", var5); ServletContext context = config.getServletContext(); context.log("SafeDispatcherServlet: \nThe Spring DispatcherServlet we wrap threw on init.\nBut for our having caught this error, the servlet would not have initialized.", var5); context.setAttribute("exceptionCaughtByServlet", var5); } } public void service(ServletRequest req, ServletResponse resp) throws ServletException, IOException { if (this.initSuccess) { this.delegate.service(req, resp); } else { throw new ApplicationContextException("Unable to initialize application context."); } } }
cas服务端配置的servlet,
org.jasig.cas.web.init.SafeDispatcherServlet 这个Servlet主要是进行转发,将接收到的请求转交给webflow来处理。
它实际上是spring-webflow的应用
有关spring-webflow的详细介绍,
网上铺天盖地,我就不啰嗦了
cas server端的web.xml文件里面有
<servlet>
<servlet-name>cas</servlet-name>
<servlet-class>
org.jasig.cas.web.init.SafeDispatcherServlet
</servlet-class>
<init-param>
<param-name>publishContext</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
这个是login-webflow的入口servlet,映射的url-pattern之一就是
<servlet-mapping>
<servlet-name>cas</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
即login
spring webflow必须在flow-registry里面注册,
这个是在cas-servlet.xml里面注册的
<webflow:flow-registry id="flowRegistry" flow-builder-services="builder">
<webflow:flow-location path="/WEB-INF/login-webflow.xml" id="login" />
</webflow:flow-registry>
对应的view properties在propertyFileConfigurer.xml中指定了