1
是否有單元測試過濾器如下?如何Junit測試servlet-filters
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException,
ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
String param = request.getParameter("param");
if (param == null) {
response.sendError(400, "param can't be null");
return;
}
看看這一個:http://stackoverflow.com/questions/11451917/how-do-i-unit-test-a-serlvet-filter-with-junit – 2013-03-05 16:07:20