首页上一页 1 下一页尾页 1 条记录 1/1页
Server Tomcat v8.0 Server at localhost failed to start.
发表在JavaWeb图书答疑
2015-10-24
是否精华
是
否
版块置顶:
是
否
[font size=4]出现这个问题后我清理了服务器数据,修改端口,增加TimeOut的start的时间值还是同样的问题。然后从新删除服务器重新配置还是同样出现这样的问题,请各位老师帮帮忙![/font][font size=5][/font]
[font size=3]<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h2>
欢迎光临,<br>
您是本站的第【
<%=application.getAttribute("count") %>
】位访客!
</h2>
</body>
</html>
package com.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
/**
* Servlet Filter implementation class CountFilter
*/
public class CountFilter_001 implements Filter {
// 来访数量
private int count;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
// 获取初始化参数
String param = filterConfig.getInitParameter("count");
// 将字符串转换为int
count = Integer.valueOf(param);
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// 访问数量自增
count ++;
// 将ServletRequest转换成HttpServletRequest
HttpServletRequest req = (HttpServletRequest) request;
// 获取ServletContext
ServletContext context = req.getSession().getServletContext();
// 将来访数量值放入到ServletContext中
context.setAttribute("count", count);
// 向下传递过滤器
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}
<filter>
<filter-name>CountFilter_001</filter-name>
<filter-class>com.filter.CountFilter_001</filter-class>
<init-param>
<param-name>count</param-name>
<param-value>5000</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CountFilter_001</filter-name>
<url-pattern>/index.jsp</url-pattern>
</filter-mapping>[/font]
[font size=3]<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h2>
欢迎光临,<br>
您是本站的第【
<%=application.getAttribute("count") %>
】位访客!
</h2>
</body>
</html>
package com.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
/**
* Servlet Filter implementation class CountFilter
*/
public class CountFilter_001 implements Filter {
// 来访数量
private int count;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
// 获取初始化参数
String param = filterConfig.getInitParameter("count");
// 将字符串转换为int
count = Integer.valueOf(param);
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// 访问数量自增
count ++;
// 将ServletRequest转换成HttpServletRequest
HttpServletRequest req = (HttpServletRequest) request;
// 获取ServletContext
ServletContext context = req.getSession().getServletContext();
// 将来访数量值放入到ServletContext中
context.setAttribute("count", count);
// 向下传递过滤器
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}
<filter>
<filter-name>CountFilter_001</filter-name>
<filter-class>com.filter.CountFilter_001</filter-class>
<init-param>
<param-name>count</param-name>
<param-value>5000</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CountFilter_001</filter-name>
<url-pattern>/index.jsp</url-pattern>
</filter-mapping>[/font]