java Web 部署到Tomcat上的时候报下面这个错误
SEVERE: Exception starting filter redisp
java.lang.ClassNotFoundException: com.yazs.util.ReDispatcherFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:256)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
貌似是找不到这个类
Web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>UploadServlet</servlet-name>
<servlet-class>com.yazs.servlet.UploadServlet</servlet-class>
<init-param>
<param-name>filePath</param-name>
<param-value>/WebContent/page/admin/upload</param-value>
</init-param>
<init-param>
<param-name>tempFilePath</param-name>
<param-value>/WebContent/page/admin/temp</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/WebContent/page/admin/add_photo/upload</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ExportExcelSerlvet</servlet-name>
<servlet-class>com.yazs.servlet.ExportExcelSerlvet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ExportExcelSerlvet</servlet-name>
<url-pattern>/WebContent/page/admin/add_photo/export</url-pattern>
</servlet-mapping>
<filter>
<filter-name>redisp</filter-name>
<filter-class>com.yazs.util.ReDispatcherFilter</filter-class>
<init-param>
<param-name>includeServlets</param-name>
<param-value>UploadServlet</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>redisp</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
UploadServlet :
package com.yazs.servlet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.servlet.*;
import org.apache.commons.fileupload.disk.*;
public class UploadServlet extends HttpServlet {
private String filePath; //存放上传文件的目录
private String tempFilePath; //存放临时文件的目录
public void init(ServletConfig config)throws ServletException {
super.init(config);
filePath=config.getInitParameter("filePath");
tempFilePath=config.getInitParameter("tempFilePath");
filePath=getServletContext().getRealPath(filePath);
tempFilePath=getServletContext().getRealPath(tempFilePath);
}
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/plain");
//向客户端发送响应正文
PrintWriter outNet=response.getWriter();
try{
//创建一个基于硬盘的FileItem工厂
DiskFileItemFactory factory = new DiskFileItemFactory();
//设置向硬盘写数据时所用的缓冲区的大小,此处为4K
factory.setSizeThreshold(4*1024);
//设置临时目录
factory.setRepository(new File(tempFilePath));
//创建一个文件上传处理器
ServletFileUpload upload = new ServletFileUpload(factory);
//设置允许上传的文件的最大尺寸,此处为4M
upload.setSizeMax(4*1024*1024);
List /* FileItem */ items = upload.parseRequest(request);
System.out.println(items);
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if(item.isFormField()) {
processFormField(item,outNet); //处理普通的表单域
}else{
processUploadedFile(item,outNet); //处理上传文件
}
}
outNet.close();
}catch(Exception e){
throw new ServletException(e);
}
}
private void processFormField(FileItem item,PrintWriter outNet) throws UnsupportedEncodingException{
String name = item.getFieldName();
String value = item.getString("UTF-8");
outNet.println(name+":"+value+"\r\n");
}
private void processUploadedFile(FileItem item,PrintWriter outNet)throws Exception{
String filename=item.getName();
int index=filename.lastIndexOf("\");
filename=filename.substring(index+1,filename.length());
long fileSize=item.getSize();
if(filename.equals("") && fileSize==0)return;
File isCreat = new File("filePath");
if(!isCreat.exists()){//判断存放上传目录是否存在
isCreat.mkdirs();
}
File uploadedFile = new File(filePath+"/"+filename);
item.write(uploadedFile);
outNet.println(filename+" is saved.");
outNet.println("The size of " +filename+" is "+fileSize+"\r\n");
}
}
有谁知道是怎么回事吗?在线等待
[解决办法]
com.yazs.util.ReDispatcherFilter 找不到这个类
[解决办法]
<filter-class>com.yazs.util.ReDispatcherFilter</filter-class>
[解决办法]
过滤器找不到 com.yazs.util.ReDispatcherFilter这个类
是不是路径写错了或者单词写错了
[解决办法]
很明显类找不到,
1,路径问题。。。2,没有把那个类发布上去。