--------- web. xml configuration
xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee http://java. sun.com/xml/ns/javaee/web-app_2_5.xsd ">
----- AutoSetUserAdapterFilter
package cn.util;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.jasig.cas.client.validation.Assertion;
/ **
* CAS single sign- filter function class is used to automatically generate the sub-application 's landing Session
*
* /
public class AutoSetUserAdapterFilter implements Filter {
/ **
* Default constructor.
* /
public AutoSetUserAdapterFilter () {
}
/ **
* @ see Filter # destroy ()
* /
public void destroy () {
}
public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
/ / _const_cas_assertion_ is stored in CAS 's session login user name signs
Object object = httpRequest.getSession (). getAttribute ("_const_cas_assertion_"); ;
System.out.println ("-------------" + object);
if (object! = null) {
Assertion assertion = ( Assertion) object;
String loginName = assertion . getPrincipal (). getName ();
System.out.println (" ------------- "+ object);
/ / first login system
}
chain.doFilter (request, response);
}
/ **
* @ see Filter # init (FilterConfig)
* /
public void init (FilterConfig fConfig) throws ServletException {
System.out.println ("-------- initialization AutoSetUserAdapterFilter -----");
}
}
------ Solution ------------------------------------ --------
filter server startup time will not go
------ Solution ------------------- -------------------------
indeed . . Start time seemingly not enter, but access to what the project should be into any page . .
startup want to go , then, seemingly only use ServletContextListener or HttpSessionListener, and then in the web.xml
------ Solution ---------------------------------------- ----
rid of your constructor
------ Solution ---------------------------- ----------------
------ For reference only -------------------------------------- -
but I do not visit when he walked jsp , it is more surprising
------ For reference only ------------------ ---------------------
I have direct access to jsp pages he did not go, I , I have a print [ doFilter System.out.println ("-------------" + object); }
did not print , breakpoints did not go, I do not know tomcat configuration problem , or the code where there are problems . Items can also be a normal visit, tragedy ....
------ For reference only -------------------------- -------------
this I have also tried , the effect is the same
------ For reference only ---------- -----------------------------
solve the problem, the cause may be the mouse to drag , web.xml wrong location , onto the outside of the web-info . Thank you
没有评论:
发表评论