org.apache.struts2.dispatcher.ng.filter.strutspreparefilterAndExecuteFilter是struts 2提供的过滤器类吗

Struts2通过注解来实现拦截器 -
- ITeye博客
博客分类:
首页写一个自定义的拦截器类MyInterceptor,实现Interceptor接口(或者继承自AbstractInterceptor)的类。
Interceptor接口声明了三个方法:
public interface Interceptor extends Serializable {
void destroy();
void init();
String intercept(ActionInvocation invocation) throws E
nit方法在拦截器类被创建之后,在对Action镜像拦截之前调用,相当于一个post-constructor方法,
使用这个方法可以给拦截器类做必要的初始话操作。
Destroy方法在拦截器被垃圾回收之前调用,用来回收init方法初始化的资源。
Intercept是拦截器的主要拦截方法,如果需要调用后续的Action或者拦截器,只需要在该方法中调用
invocation.invoke()方法即可,在该方法调用的前后可以插入Action调用前后拦截器需要做的方法。
如果不需要调用后续的方法,则返回一个String类型的对象即可,例如Action.SUCCESS。
另外AbstractInterceptor提供了一个简单的Interceptor的实现,这个实现为:
public abstract class AbstractInterceptor implements Interceptor {
public void init() {
public void destroy() {
public abstract String intercept(ActionInvocation invocation) throws E
在不需要编写init和destroy方法的时候,只需要从AbstractInterceptor继承而来,实现intercept方法即可。
我们尝试编写一个拦截器,该拦截器,代码为:
package com.sunny.
import com.opensymphony.xwork2.ActionI
import com.opensymphony.xwork2.interceptor.I
public class MyInterceptor implements Interceptor {
private static final long serialVersionUID = 1L;
public void init() {
System.out.println("init");
public String intercept(ActionInvocation invoker) throws Exception {
System.out.println("intercept");
String result = invoker.invoke();
public void destroy() {
System.out.println("destory");
然后定义在struts.xml中注册拦截器
&?xml version="1.0" encoding="UTF-8" ?&
&!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"&
&!-- 请求参数的编码方式 --&
&constant name="struts.i18n.encoding" value="UTF-8" /&
&package name="custom-default" extends="struts-default"&
&interceptors&
&interceptor name="annotationInterceptor" class="com.sunny.action.MyInterceptor" /&
&interceptor-stack name="annotatedStack"&
&interceptor-ref name="annotationInterceptor" /&
&interceptor-ref name="defaultStack" /&
&/interceptor-stack&
&/interceptors&
&!-- 设置全局 全局默认的拦截器栈--&
&default-interceptor-ref name="annotatedStack"&&/default-interceptor-ref&
&/package&
最后在Action类中通过注解引用
package com.sunny.
import org.apache.struts2.convention.annotation.A
import org.apache.struts2.convention.annotation.ExceptionM
import org.apache.struts2.convention.annotation.ExceptionM
import org.apache.struts2.convention.annotation.InterceptorR
import org.apache.struts2.convention.annotation.InterceptorR
import org.apache.struts2.convention.annotation.N
import org.apache.struts2.convention.annotation.ParentP
import org.apache.struts2.convention.annotation.R
import com.opensymphony.xwork2.ActionS
import com.sunny.entity.U
@ParentPackage("custom-default")
@Namespace("/login")
// 公共异常捕获
@ExceptionMappings({ @ExceptionMapping(exception = "java.lang.Exception", result = "exception") })
@InterceptorRefs({ @InterceptorRef("annotatedStack") })
public class LoginAction extends ActionSupport {
private static final long serialVersionUID = 1L;
public Users getUsers() {
public void setUsers(Users users) {
this.users =
@Action(value = "add", results = {
@Result(name = "success", location = "/a.jsp"),
@Result(name = "error", location = "/index.jsp") })
public String execute() throws Exception {
if (users.getUsername().equals("sunny")
&& users.getPassword().equals("sunny")) {
return "success";
return "error";
完成后启动服务就可以看到自定义的拦截器输出init
在浏览器中输入:http://localhost:8080/Struts2/login/add.action调用execute()后会看到输出intercept。之后停止服务会看到输出destory。
一个简单的拦截器已经配置完成。
浏览: 36574 次
来自: 西安
@Resource(name=&loginfoIn ...Struts2整合SiteMesh - 苦今生修来世 - ITeye博客
博客分类:
1.导入Struts2的jar 和 sitemesh.jar 和 Struts2-sitemesh-plugin.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang3-3.1.jar
commons-logging-1.1.1.jar
freemarker-2.3.19.jar
javassist-3.11.0.GA.jar
ognl-3.0.5.jar
sitemesh-2.4.2.jar
struts2-core-2.3.4.jar
struts2-sitemesh-plugin-2.3.4.1.jar
xwork-core-2.3.4.jar
2.在web.xml中配置 Struts sitemesh拦截器 注意有一定的顺序
&?xml version="1.0" encoding="UTF-8"?&
&web-app version="2.5"
xmlns="/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="/xml/ns/javaee
/xml/ns/javaee/web-app_2_5.xsd"&
&!--用来消除sitemesh 拦截器 Struts2拦截器的冲突 使之兼容--&
&filter-name&struts-cleanup&/filter-name&
&filter-class&org.apache.struts2.dispatcher.ActionContextCleanUp&/filter-class&
&filter-name&sitemesh&/filter-name&
&filter-class&com.opensymphony.module.sitemesh.filter.PageFilter&/filter-class&
&filter-name&struts2&/filter-name&
&filter-class&org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter&/filter-class&
&filter-mapping&
&filter-name&struts-cleanup&/filter-name&
&url-pattern&/*&/url-pattern&
&/filter-mapping&
&filter-mapping&
&filter-name&sitemesh&/filter-name&
&url-pattern&/*&/url-pattern&
&/filter-mapping&
&filter-mapping&
&filter-name&struts2&/filter-name&
&url-pattern&/*&/url-pattern&
&/filter-mapping&
&welcome-file-list&
&welcome-file&index.jsp&/welcome-file&
&/welcome-file-list&
&/web-app&
3.在webroot下的descorators目录下建立 myDecorator.jsp 装饰器页面
&%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%&
&%@ taglib prefix="decorator" uri="/sitemesh/decorator" %&
&%@ taglib prefix="page" uri="/sitemesh/page" %&
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
&!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&
&base href="&%=basePath%&"&
&title&&decorator:title default="装饰器页面"/&&/title&
&decorator:head/&
&div&top&/div&
&decorator:body/&
&div&bottom&/div&
4.在web-inf 下建立 装饰器描述文件 decorators.xml
&?xml version="1.0" encoding="UTF-8"?&
&decoratos defaultdir="/decorators"&
&decorator name="myDecorator" page="myDecorator.jsp"&
&pattern&/songs/*&/pattern&
&/decorator&
&/decoratos&
5.建立 实体类 Song.java
private String songN
private String songT
package com.sh.
import java.util.ArrayL
import java.util.L
import com.opensymphony.xwork2.ActionS
import com.sh.entity.S
public class AllSongs extends ActionSupport {
private List&Song& allSongs=new ArrayList&Song&();
public List&Song& getAllSongs() {
return allS
public void setAllSongs(List&Song& allSongs) {
this.allSongs = allS
public String execute() throws Exception {
// TODO Auto-generated method stub
Song song1=new Song();
song1.setSongName("浪子心声");
song1.setSinger("刘德华");
song1.setSongTime("3:41");
Song song2=new Song();
song2.setSongName("中国话");
song2.setSinger("SHE");
song2.setSongTime("4:18");
Song song3=new Song();
song3.setSongName("丁香花");
song3.setSinger("唐磊");
song3.setSongTime("4:05");
allSongs.add(song1);
allSongs.add(song2);
allSongs.add(song3);
return SUCCESS;
7.配置& struts.xml
&?xml version="1.0" encoding="UTF-8" ?&
&!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd"&
&constant name="struts.i18n.encoding" value="utf-8"/&
&package name="default" extends="struts-default" namespace="/songs"&
&action name="allSongs" class="com.sh.action.AllSongs"&
&result&/allSongs.jsp&/result&
&/package&
8.allSongs.jsp
&%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%&
&%@ taglib uri="/struts-tags" prefix="s" %&
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
&!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&
&base href="&%=basePath%&"&
&title&Struts2AndStieMesh&/title&
&ul style="list-style: none"&
&li style="float: width: 100"&歌名&/li&
&li style="float: width: 100"&歌手&/li&
&li style="float: width: 100"&时长&/li&
&div style="clear:"&&/div&
&s:iterator value="allSongs"&
&ul style="list-style:none"&
&li style="float: width: 100"&&s:property value="songName"/&&/li&
&li style="float: width: 100"&&s:property value="singer"/&&/li&
&li style="float: width: 100"&&s:property value="songTime"/&&/li&
&div style="clear:"&&/div&
&/s:iterator&
9.访问localhost:8080/Struts2AndSiteMesh/songs/allSongs.action 可以看到 页面中加入
& top 和bottom
& 如果将 decorations.xml中的pattern 改成 &pattern&/singer/*&/pattern&
& 那上面的访问的页面就没有经过装饰器页面 修饰
下载次数: 140
浏览: 1000328 次
来自: 上海
这个挺好JavaScript实现input输入框控件只允许输入 ...
东西太好啦受教啊
naiyizute 写道编码表好像不全,能提供全一点的吗htt ...
你这个 EmojiConverter 是来自这里吧,一个日本人 ...
写的真好,根据这篇搭建文章,我自己整理了一下,完整的包和可以在 ...org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
14 messages
Open this post in threaded view
Report Content as Inappropriate
org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
I am fairly new to Struts. I'm trying to get an application which uses Struts to work on Glassfish v3. I have made it work on JBoss and Tomcat.
If I put struts2-core-2.1.8.jar in the classpath, loading the application triggers the error message:
WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
& & & & at com.sun.enterprise.web.WebContainer.createFilterInstance(WebContainer.java:715)
& & & & at com.sun.enterprise.web.WebModule.createFilterInstance(WebModule.java:1948)
& & & & at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:248)
& & & & at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
& & & & at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
& & & & at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
& & & & at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
& & & & at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
& & & & at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
& & & & at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
& & & & at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
& & & & at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
& & & & at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
& & & & at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
& & & & at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
& & & & at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
& & & & at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
& & & & at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
& & & & at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
& & & & at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
& & & & at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
& & & & at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
& & & & at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
& & & & at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
& & & & at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
& & & & at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
& & & & at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
& & & & at java.lang.Thread.run(Thread.java:619)
When I remove the jar, I can load the application until I hit the error:
java.lang.ClassNotFoundException: org.apache.struts2.interceptor.ServletRequestAware
& & & & at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
& & & & at java.security.AccessController.doPrivileged(Native Method)
& & & & at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
& & & & at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
& & & & at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
& & & & at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
& & & & at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
& & & & ... 115 more
Which indicates that Struts isn't in the classpath.
Does anyone have any idea what is wrong?
Open this post in threaded view
Report Content as Inappropriate
Re: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to
javax.servlet.Filter
Hallgrímur Th. Bj?rnsson &&:
& I am fairly new to Struts. I'm trying to get an application which uses Struts to work on Glassfish v3. I have made it work on JBoss and Tomcat.
Try to use one of these
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
or (when you are using Sutemesh)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
Kapitu?a Javarsovia 2010
---------------------------------------------------------------------
To unsubscribe, e-mail:
For additional commands, e-mail:
Open this post in threaded view
Report Content as Inappropriate
RE: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to
javax.servlet.Filter
Thanks for the reply.
Where is this typically changed? In an XML file or in the code?
Kve?ja / Regards,
Hallgrímur
-----Original Message-----
From: Lukasz Lenart [mailto:]
Sent: 23. mars
To: Struts Users Mailing List
Subject: Re: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
Hallgrímur Th. Bj?rnsson &&:
& I am fairly new to Struts. I'm trying to get an application which uses Struts to work on Glassfish v3. I have made it work on JBoss and Tomcat.
Try to use one of these
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
or (when you are using Sutemesh)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
Kapitu?a Javarsovia 2010
---------------------------------------------------------------------
To unsubscribe, e-mail:
For additional commands, e-mail:
Open this post in threaded view
Report Content as Inappropriate
RE: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to
javax.servlet.Filter
I found where to change the filter settings.
I get the exact same errors with the different filters:
java.lang.ClassCastException: org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter cannot be cast to javax.servlet.Filter
For all 3 filters you suggested.
Kve?ja / Regards,
Hallgrímur
-----Original Message-----
From: Hallgrímur Th. Bj?rnsson [mailto:]
Sent: 23. mars
To: Struts Users Mailing L
Subject: RE: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
Thanks for the reply.
Where is this typically changed? In an XML file or in the code?
Kve?ja / Regards,
Hallgrímur
-----Original Message-----
From: Lukasz Lenart [mailto:]
Sent: 23. mars
To: Struts Users Mailing List
Subject: Re: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
Hallgrímur Th. Bj?rnsson &&:
& I am fairly new to Struts. I'm trying to get an application which uses Struts to work on Glassfish v3. I have made it work on JBoss and Tomcat.
Try to use one of these
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
or (when you are using Sutemesh)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
Kapitu?a Javarsovia 2010
---------------------------------------------------------------------
To unsubscribe, e-mail:
For additional commands, e-mail:
Open this post in threaded view
Report Content as Inappropriate
[Struts 2.1.8] s:url : how to open in a new window ?
I am using Struts 2.1.8.
In a JSP, I have a link which calls an action. I want to open that link in a new window. The following code works :
&s:url id=&genererRapportPDF& action=&affichePDF& windowState=&& /&
&s:a href=&%{genererRapportPDF}& onclick=&javascript:window.open('%{genererRapportPDF}');&&Generation&/s:a&
The problem is that it also calls the action / opens the link in the current window.
How to avoid that ?
Open this post in threaded view
Report Content as Inappropriate
RE: [Struts 2.1.8] s:url : how to open in a new window ?
This is a JS thing. Try:
onclick=&javascript:window.open('%{genererRapportPDF}');&
-----Mensagem original-----
De: Celinio Fernandes [mailto:]
Enviada: ter?a-feira, 23 de Mar?o de
Para: Struts Users Mailing List
Assunto: [Struts 2.1.8] s:url : how to open in a new window ?
I am using Struts 2.1.8.
In a JSP, I have a link which calls an action. I want to open that link in a
new window. The following code works :
&s:url id=&genererRapportPDF& action=&affichePDF& windowState=&& /&
&s:a href=&%{genererRapportPDF}&
onclick=&javascript:window.open('%{genererRapportPDF}');&&Generation&/s:a&
The problem is that it also calls the action / opens the link in the current
How to avoid that ?
---------------------------------------------------------------------
To unsubscribe, e-mail:
For additional commands, e-mail:
Open this post in threaded view
Report Content as Inappropriate
Re: [Struts 2.1.8] s:url : how to open in a new window ?
How about using
target=&_blank&
instead of onclick?
Gustavo Felisberto schrieb:
& This is a JS thing. Try:
& onclick=&javascript:window.open('%{genererRapportPDF}');&
& -----Mensagem original-----
& De: Celinio Fernandes [mailto:]
& Enviada: ter?a-feira, 23 de Mar?o de
& Para: Struts Users Mailing List
& Assunto: [Struts 2.1.8] s:url : how to open in a new window ?
& I am using Struts 2.1.8.
& In a JSP, I have a link which calls an action. I want to open that link in a
& new window. The following code works :
& &&s:url id=&genererRapportPDF& action=&affichePDF& windowState=&& /&
& & &s:a href=&%{genererRapportPDF}&
& onclick=&javascript:window.open('%{genererRapportPDF}');&&Generation&/s:a&
& The problem is that it also calls the action / opens the link in the current
& How to avoid that ?
& Thanks. &
& ---------------------------------------------------------------------
& To unsubscribe, e-mail:
& For additional commands, e-mail:
---------------------------------------------------------------------
To unsubscribe, e-mail:
For additional commands, e-mail:
Open this post in threaded view
Report Content as Inappropriate
Re: [Struts 2.1.8] s:url : how to open in a new window ?
In reply to
by Celinio Fernandes-2
What if I'm using the app, and I want to open the link in a new tab
instead? &Or how about, I want to open it in the same tab and just use
the back button once I'm done looking at the PDF?
On Tue, Mar 23, 2010 at 8:02 AM, Celinio Fernandes && wrote:
& I am using Struts 2.1.8.
& In a JSP, I have a link which calls an action. I want to open that link in a new window. The following code works :
&s:url id=&genererRapportPDF& action=&affichePDF& windowState=&& /&
&s:a href=&%{genererRapportPDF}& onclick=&javascript:window.open('%{genererRapportPDF}');&&Generation&/s:a&
& The problem is that it also calls the action / opens the link in the current window.
& How to avoid that ?
---------------------------------------------------------------------
To unsubscribe, e-mail:
For additional commands, e-mail:
Open this post in threaded view
Report Content as Inappropriate
Re: [Struts 2.1.8] s:url : how to open in a new window ?
In reply to
by Robert Graf-Waczenski
Target blank isn't necessarily available (e.g. writing the site in xhtml 1.1)
On Tue, Mar 23, 2010 at 10:06 AM, Robert Graf-Waczenski && wrote:
& How about using
& target=&_blank&
& instead of onclick?
& Gustavo Felisberto schrieb:
&& This is a JS thing. Try:
&& onclick=&javascript:window.open('%{genererRapportPDF}');&
&& Gustavo
&& -----Mensagem original-----
&& De: Celinio Fernandes [mailto:] Enviada: ter?a-feira, 23
&& de Mar?o de
&& Para: Struts Users Mailing List
&& Assunto: [Struts 2.1.8] s:url : how to open in a new window ?
&& I am using Struts 2.1.8.
&& In a JSP, I have a link which calls an action. I want to open that link in
&& new window. The following code works :
&s:url id=&genererRapportPDF& action=&affichePDF& windowState=&& /&
&& &s:a href=&%{genererRapportPDF}&
&& onclick=&javascript:window.open('%{genererRapportPDF}');&&Generation&/s:a&
The problem is that it also calls the action / opens the link in the
&& current
&& window.
&& How to avoid that ?
&& Thanks.
&& ---------------------------------------------------------------------
&& To unsubscribe, e-mail:
&& For additional commands, e-mail:
& ---------------------------------------------------------------------
& To unsubscribe, e-mail:
& For additional commands, e-mail:
---------------------------------------------------------------------
To unsubscribe, e-mail:
For additional commands, e-mail:
Open this post in threaded view
Report Content as Inappropriate
Re: [Struts 2.1.8] s:url : how to open in a new window ?
In reply to
by Celinio Fernandes-2
You can avoid opening of the link in the current window removing the
href attribute from &s:a& tag.
Florin Cazacu.
Celinio Fernandes wrote:
& I am using Struts 2.1.8.
& In a JSP, I have a link which calls an action. I want to open that link in a new window. The following code works :
& &&s:url id=&genererRapportPDF& action=&affichePDF& windowState=&& /&
& & &s:a href=&%{genererRapportPDF}& onclick=&javascript:window.open('%{genererRapportPDF}');&&Generation&/s:a& &
& The problem is that it also calls the action / opens the link in the current window.
& How to avoid that ?
& Thanks. &
---------------------------------------------------------------------
To unsubscribe, e-mail:
For additional commands, e-mail:
Open this post in threaded view
Report Content as Inappropriate
Re: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to
javax.servlet.Filter
In reply to
by Hallgrímur Th. Bj?rnsson
That error doesn't make a lot of sense... Check a few of the following -
Which version of Glassfish are you using (2.x, 3)
Restart glassfish
Make sure that you don't have servlet.jar or jsp-api.jar in your /WEB-INF/lib
Deploy the app to another container (jetty or tomcat) to make sure
that your app isn't the problem
As you can see, I'm grasping straws...
Hallgrímur Th. Bj?rnsson &&:
& I found where to change the filter settings.
& I get the exact same errors with the different filters:
& java.lang.ClassCastException: org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter cannot be cast to javax.servlet.Filter
& For all 3 filters you suggested.
& Kve?ja / Regards,
& Hallgrímur
& -----Original Message-----
& From: Hallgrímur Th. Bj?rnsson [mailto:]
& Sent: 23. mars
& To: Struts Users Mailing L
& Subject: RE: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
& Thanks for the reply.
& Where is this typically changed? In an XML file or in the code?
& Kve?ja / Regards,
& Hallgrímur
& -----Original Message-----
& From: Lukasz Lenart [mailto:]
& Sent: 23. mars
& To: Struts Users Mailing List
& Subject: Re: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
Hallgrímur Th. Bj?rnsson &&:
&& I am fairly new to Struts. I'm trying to get an application which uses Struts to work on Glassfish v3. I have made it work on JBoss and Tomcat.
& Try to use one of these
& org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
& or (when you are using Sutemesh)
& org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
& org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
& & Kapitu?a Javarsovia 2010
& ---------------------------------------------------------------------
& To unsubscribe, e-mail:
& For additional commands, e-mail:
Wes Wannemacher
Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!
---------------------------------------------------------------------
To unsubscribe, e-mail:
For additional commands, e-mail:
Open this post in threaded view
Report Content as Inappropriate
RE: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to
javax.servlet.Filter
The chief Struts build and release engineer from ohio put that into the latest 2.1.8 distro..
import javax.servlet.Filter
public class FilterDispatcher implements StrutsStatics, Filter {
d/l the struts-2.1.8 distro if you need that functionality
my danish is rusty but here goes
*Tak a Miget*
Martin Gainty
______________________________________________
Note de déni et de confidentialité
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. ?tant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
& Date: Wed, 24 Mar :45 -0400
& Subject: Re: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
& That error doesn't make a lot of sense... Check a few of the following -
& Which version of Glassfish are you using (2.x, 3)
& Restart glassfish
& Make sure that you don't have servlet.jar or jsp-api.jar in your /WEB-INF/lib
& Deploy the app to another container (jetty or tomcat) to make sure
& that your app isn't the problem
& As you can see, I'm grasping straws...
Hallgrímur Th. Bj?rnsson &&:
& & I found where to change the filter settings.
& & I get the exact same errors with the different filters:
& & java.lang.ClassCastException: org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter cannot be cast to javax.servlet.Filter
& & For all 3 filters you suggested.
& & Kve?ja / Regards,
& & Hallgrímur
& & -----Original Message-----
& & From: Hallgrímur Th. Bj?rnsson [mailto:]
& & Sent: 23. mars
& & To: Struts Users Mailing L
& & Subject: RE: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
& & Thanks for the reply.
& & Where is this typically changed? In an XML file or in the code?
& & Kve?ja / Regards,
& & Hallgrímur
& & -----Original Message-----
& & From: Lukasz Lenart [mailto:]
& & Sent: 23. mars
& & To: Struts Users Mailing List
& & Subject: Re: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
Hallgrímur Th. Bj?rnsson &&:
& && I am fairly new to Struts. I'm trying to get an application which uses Struts to work on Glassfish v3. I have made it work on JBoss and Tomcat.
& & Try to use one of these
& & org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
& & or (when you are using Sutemesh)
& & org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
& & org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
& & Regards
& & ?ukasz
& & & & Kapitu?a Javarsovia 2010
& & ---------------------------------------------------------------------
& & To unsubscribe, e-mail:
& & For additional commands, e-mail:
& Wes Wannemacher
& Head Engineer, WanTii, Inc.
& Need Training? Struts, Spring, Maven, Tomcat...
& Ask me for a quote!
& ---------------------------------------------------------------------
& To unsubscribe, e-mail:
& For additional commands, e-mail:
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
Open this post in threaded view
Report Content as Inappropriate
RE: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to
javax.servlet.Filter
Hmm, I'll need to test that.
I'm using Glassfish v3.
I did have servlet-api.jar in the classpath but after I removed it, I got a classNotFoundException.
Then I really started messing around and copied javax.servlet.jar from the Glassfish/modules directory to my domain/lib/ext directory, as a desperate measure.
Apparently, then it picked up the javax.servlet.filter class but I again got the RE: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to
javax.servlet.Filter exception.
The program works in Tomcat and JBoss.
PS. I'm not Danish.
-----Original Message-----
From: Martin Gainty [mailto:]
Sent: 24. mars
To: Struts Users Mailing List
Subject: RE: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
The chief Struts build and release engineer from ohio put that into the latest 2.1.8 distro..
import javax.servlet.Filter
public class FilterDispatcher implements StrutsStatics, Filter {
d/l the struts-2.1.8 distro if you need that functionality
my danish is rusty but here goes
*Tak a Miget*
Martin Gainty
______________________________________________
Note de déni et de confidentialité
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. ?tant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
& Date: Wed, 24 Mar :45 -0400
& Subject: Re: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
& That error doesn't make a lot of sense... Check a few of the following -
& Which version of Glassfish are you using (2.x, 3)
& Restart glassfish
& Make sure that you don't have servlet.jar or jsp-api.jar in your /WEB-INF/lib
& Deploy the app to another container (jetty or tomcat) to make sure
& that your app isn't the problem
& As you can see, I'm grasping straws...
Hallgrímur Th. Bj?rnsson &&:
& & I found where to change the filter settings.
& & I get the exact same errors with the different filters:
& & java.lang.ClassCastException: org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter cannot be cast to javax.servlet.Filter
& & For all 3 filters you suggested.
& & Kve?ja / Regards,
& & Hallgrímur
& & -----Original Message-----
& & From: Hallgrímur Th. Bj?rnsson [mailto:]
& & Sent: 23. mars
& & To: Struts Users Mailing L
& & Subject: RE: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
& & Thanks for the reply.
& & Where is this typically changed? In an XML file or in the code?
& & Kve?ja / Regards,
& & Hallgrímur
& & -----Original Message-----
& & From: Lukasz Lenart [mailto:]
& & Sent: 23. mars
& & To: Struts Users Mailing List
& & Subject: Re: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Filter
Hallgrímur Th. Bj?rnsson &&:
& && I am fairly new to Struts. I'm trying to get an application which uses Struts to work on Glassfish v3. I have made it work on JBoss and Tomcat.
& & Try to use one of these
& & org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
& & or (when you are using Sutemesh)
& & org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
& & org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
& & Regards
& & ?ukasz
& & & & Kapitu?a Javarsovia 2010
& & ---------------------------------------------------------------------
& & To unsubscribe, e-mail:
& & For additional commands, e-mail:
& Wes Wannemacher
& Head Engineer, WanTii, Inc.
& Need Training? Struts, Spring, Maven, Tomcat...
& Ask me for a quote!
& ---------------------------------------------------------------------
& To unsubscribe, e-mail:
& For additional commands, e-mail:
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
---------------------------------------------------------------------
To unsubscribe, e-mail:
For additional commands, e-mail:
javax.servlet.jar (111K)
Open this post in threaded view
Report Content as Inappropriate
Re: [Struts 2.1.8] s:url : how to open in a new window ?
In reply to
by Florin Cazacu-3
Thanks, that works :)
--- On Tue, 3/23/10, Florin Cazacu && wrote:
From: Florin Cazacu &&
Subject: Re: [Struts 2.1.8] s:url : how to open in a new window ?
To: &Struts Users Mailing List& &&
Date: Tuesday, March 23,
You can avoid opening of the link in the current window removing the href attribute from &s:a& tag.
Florin Cazacu.
Celinio Fernandes wrote:
& I am using Struts 2.1.8.
& In a JSP, I have a link which calls an action. I want to open that link in a new window. The following code works :
&s:url id=&genererRapportPDF& action=&affichePDF& windowState=&& /&
&s:a href=&%{genererRapportPDF}& onclick=&javascript:window.open('%{genererRapportPDF}');&&Generation&/s:a&
The problem is that it also calls the action / opens the link in the current window.
& How to avoid that ?
---------------------------------------------------------------------
To unsubscribe, e-mail:
For additional commands, e-mail:
Loading...

我要回帖

更多关于 struts2 filter class 的文章

 

随机推荐