部署struts2常见一些问题

1.java.lang.ClassNotFoundException: javassist.ClassPool
 
解决:需要引入javassist-3.7.ga.jar,而这个在struts-2.2.1\lib下是没有的,需要在struts-   2.2.1\apps\struts2-blank-2.2.1.war下的lib中找。”

2.org.apache.jasper.JasperException: The Struts dispatcher cannot be found.  This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]

  解决:需在web.xml 配置struts2 过滤器的信息,当请求通过servlet 的过滤器的时候就会初始化struts2 标签所需的dispatcher
  配置如下:
   <filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jsp</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>

3.com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public void com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.setObjectFactory(com.opensymphony.xwork2.ObjectFactory). - Class: com.opensymphony.xwork2.inject.ContainerImpl
找不到default 的依赖
解决:
   在struts.xml文件中添加配置:
   <include file="struts-default.xml"></include>


4.在Spring配置文件中配置的类在struts2中找不到
解决:
   在struts.xml 文件中添加常量配置:
  <constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
这样在Spring中配置的类在struts中才可以被重写

你可能感兴趣的:(apache,jsp,xml,servlet,struts)