You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by xnpeng <xn...@163.com> on 2009/05/28 03:11:12 UTC

How to setup Interceptor when using struts2.1.6 rest plugin with convention

Hi,
  when i use rest-plugin with convention plugin in struts2.1.6, i cannot setup my interceptor. the following is my interceptor and config file.
i cannot see the println result on console.
  can anyone help? thank you!

public class SimpleInterceptor extends AbstractInterceptor {
    public String intercept(ActionInvocation invocation) throws Exception {
        System.out.println("!!!!!SimpleInterceptor==date:" + (new Date()));
        return invocation.invoke();
    }
}

<?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">
<struts>
    <constant name="struts.i18n.encoding" value="UTF-8"/>
    <constant name="struts.devMode" value="false"/>
    <constant name="struts.enable.DynamicMethodInvocation" value="false"/>
    <constant name="struts.custom.i18n.resources" value="default"/>
    <constant name="struts.serve.static.browserCache" value="true"/>
    <constant name="struts.convention.action.suffix" value="Controller"/>
    <constant name="struts.convention.action.mapAllMatches" value="true"/>
    <constant name="struts.convention.default.parent.package" value="rest-default"/>
    <constant name="struts.convention.package.locators" value="rest"/>
    <constant name="struts.convention.result.path" value="/WEB-INF/content"/>
    <constant name="struts.multipart.saveDir" value="Z:\apacheroot\uploads"/>
    <constant name="struts.multipart.maxSize" value="1024000"/>
    <package name="default" namespace="/" extends="rest-default">
        <interceptors>
            <interceptor name="authentication"  class="com.xunan.framework.web.interceptor.SimpleInterceptor"/>
            <interceptor-stack name="user">
                <interceptor-ref name="authentication"/>
                <interceptor-ref name="defaultStack"/>
            </interceptor-stack>
            <interceptor-stack name="user-submit">
                <interceptor-ref name="tokenSession"/>
                <interceptor-ref name="user"/>
            </interceptor-stack>
            <interceptor-stack name="guest">
                <interceptor-ref name="defaultStack"/>
            </interceptor-stack>
        </interceptors>
        <default-interceptor-ref name="user"/>
        <global-results>
            <result name="error" type="freemarker">/error.jsp</result>
        </global-results>
        <global-exception-mappings>
            <exception-mapping exception="java.lang.Exception" result="error">
            </exception-mapping>
        </global-exception-mappings>
    </package>
    <package name="main" namespace="/post" extends="default">
        <default-interceptor-ref name="user"/>
    </package>
    
    <package name="admin" namespace="/admin" extends="default">
        <default-interceptor-ref name="user"/>
    </package>
</struts>

Re: How to setup Interceptor when using struts2.1.6 rest plugin with convention

Posted by Wes Wannemacher <we...@wantii.com>.
xnpeng,

I think you are missing the point, packages have interceptor and
interceptor stack definitions. Actions live inside of packages. What
you need to do is move your conventions actions into your package. The
interceptor ref annotation will point to the stacks you want, but it
does no good if those interceptors are not defined in the package
where those actions live. To have your actions use your package,
change the configuration from -

<constant name="struts.convention.default.parent.package" value="rest-default"/>

to -

<constant name="struts.convention.default.parent.package" value="admin"/>

Then, conventions will put the actions in your package. Once this is
done, since you have a default-interceptor-ref in your package, the
interceptor ref annotations will no longer even be necessary.

-Wes

2009/5/27 xnpeng <xn...@163.com>:
> Hi,
>  can some one help me? when i add annotation to my action,tomcat failed start.
>
> @InterceptorRefs({@InterceptorRef("user"), @InterceptorRef("defaultStack")})
> public class MainController extends MainAction {...}
> Caused by: Unable to find interceptor class referenced by ref-name user - [unknown location]
>        at com.opensymphony.xwork2.config.providers.InterceptorBuilder.constructInterceptorReference(InterceptorBuilder.java:
>        at org.apache.struts2.convention.DefaultInterceptorMapBuilder.buildInterceptorList(DefaultInterceptorMapBuilder.java:
>        at org.apache.struts2.convention.DefaultInterceptorMapBuilder.build(DefaultInterceptorMapBuilder.java:90)
>        at org.apache.struts2.convention.DefaultInterceptorMapBuilder.build(DefaultInterceptorMapBuilder.java:63)
>        at org.apache.struts2.convention.PackageBasedActionConfigBuilder.createActionConfig(PackageBasedActionConfigBuilder.j
>        at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.j
>        at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.j
>        at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:52)
>        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:200)
>        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
>

-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to setup Interceptor when using struts2.1.6 rest plugin with convention

Posted by xnpeng <xn...@163.com>.
Hi,
  can some one help me? when i add annotation to my action,tomcat failed start.
 
@InterceptorRefs({@InterceptorRef("user"), @InterceptorRef("defaultStack")})
public class MainController extends MainAction {...}
Caused by: Unable to find interceptor class referenced by ref-name user - [unknown location]
        at com.opensymphony.xwork2.config.providers.InterceptorBuilder.constructInterceptorReference(InterceptorBuilder.java:
        at org.apache.struts2.convention.DefaultInterceptorMapBuilder.buildInterceptorList(DefaultInterceptorMapBuilder.java:
        at org.apache.struts2.convention.DefaultInterceptorMapBuilder.build(DefaultInterceptorMapBuilder.java:90)
        at org.apache.struts2.convention.DefaultInterceptorMapBuilder.build(DefaultInterceptorMapBuilder.java:63)
        at org.apache.struts2.convention.PackageBasedActionConfigBuilder.createActionConfig(PackageBasedActionConfigBuilder.j
        at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.j
        at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.j
        at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:52)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:200)
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)






在2009-05-28,xnpeng <xn...@163.com> 写道:
>Hi,musachy!
>   things are going on. when i add a line to my Controller(Action):
> 
>@InterceptorRefs({@InterceptorRef("user"), @InterceptorRef("defaultStack")})
>public class MainController extends MainAction {...}
> 
>then some error happens:
>Caused by: Unable to find interceptor class referenced by ref-name user - [unknown location]
>
>again,the following is my config file.
> 
><struts>
>    <constant name="struts.i18n.encoding" value="UTF-8"/>
>    <constant name="struts.devMode" value="false"/>
>    <constant name="struts.enable.DynamicMethodInvocation" value="false"/>
>    <constant name="struts.custom.i18n.resources" value="default"/>
>    <constant name="struts.serve.static.browserCache" value="true"/>
>    <constant name="struts.convention.action.suffix" value="Controller"/>
>    <constant name="struts.convention.action.mapAllMatches" value="true"/>
>    <constant name="struts.convention.default.parent.package" value="rest-default"/>
>    <constant name="struts.convention.package.locators" value="rest"/>
>    <constant name="struts.convention.result.path" value="/WEB-INF/content"/>
>    <constant name="struts.multipart.saveDir" value="Z:\apacheroot\uploads"/>
>    <constant name="struts.multipart.maxSize" value="1024000"/>
>    <package name="default" namespace="/" extends="struts-default">
>        <interceptors>
>            <interceptor name="authentication"  class="com.xunan.framework.web.interceptor.SimpleInterceptor"/>
>            <interceptor-stack name="user">
>                <interceptor-ref name="authentication"/>
>                <interceptor-ref name="defaultStack"/>
>            </interceptor-stack>
>            <interceptor-stack name="user-submit">
>                <interceptor-ref name="tokenSession"/>
>                <interceptor-ref name="user"/>
>            </interceptor-stack>
>            <interceptor-stack name="guest">
>                <interceptor-ref name="defaultStack"/>
>            </interceptor-stack>
>        </interceptors>
>        <default-interceptor-ref name="user"/>
>        <global-results>
>            <result name="error" type="freemarker">/error.jsp</result>
>        </global-results>
>        <global-exception-mappings>
>            <exception-mapping exception="java.lang.Exception" result="error">
>            </exception-mapping>
>        </global-exception-mappings>
>    </package>
>    <package name="main" namespace="/post" extends="default">
>        <interceptors>
>            <interceptor name="authentication"  class="com.xunan.framework.web.interceptor.SimpleInterceptor"/>
>            <interceptor-stack name="user">
>                <interceptor-ref name="authentication"/>
>                <interceptor-ref name="defaultStack"/>
>            </interceptor-stack>
>            <interceptor-stack name="user-submit">
>                <interceptor-ref name="tokenSession"/>
>                <interceptor-ref name="user"/>
>            </interceptor-stack>
>            <interceptor-stack name="guest">
>                <interceptor-ref name="defaultStack"/>
>            </interceptor-stack>
>        </interceptors>
>        <default-interceptor-ref name="user"/>
>    </package>
>    
>    <package name="admin" namespace="/admin" extends="default">
>        <default-interceptor-ref name="user"/>
>    </package>
></struts>
>
> 
>
>
>在2009-05-28,"Musachy Barroso" <mu...@gmail.com> 写道:
>>that setting is telling Convention to use that package for the actions
>>it will create, and its default interceptor stack will be applied to
>>those actions. You need to make it point to your own package, which
>>defines a default interceptor stack with your interceptor. Either
>>that, or use @InterceptorRef in your actions.
>>
>>musachy
>>
>>2009/5/27 xnpeng <xn...@163.com>:
>>> hi,Musachy :
>>>   I have a line defined in config file:
>>> <constant name="struts.convention.default.parent.package" value="rest-default"/>
>>>  do you mean change to otherwise?
>>>
>>>
>>>
>>>
>>> 在2009-05-28,"Musachy Barroso" <mu...@gmail.com> 写道:
>>>>also, change this:
>>>>
>>>><constant name="struts.convention.default.parent.package" value="rest-default"/>
>>>>
>>>>and make it point to your interceptor stack, otherwise your
>>>>interceptor won't be used, unless you use the @InterceptorRef
>>>>annotation.
>>>>
>>>>musachy
>>>>
>>>>On Wed, May 27, 2009 at 9:31 PM, Dave Newton <ne...@yahoo.com> wrote:
>>>>> You're setting the default parent package to rest-default, which doesn't
>>>>> include your interceptor--have you tried setting it to the package with
>>>>> your interceptor in it?
>>>>>
>>>>> Dave
>>>>>
>>>>> xnpeng wrote:
>>>>>>
>>>>>> Hi, when i use rest-plugin with convention plugin in struts2.1.6, i
>>>>>> cannot setup my interceptor. the following is my interceptor and
>>>>>> config file. i cannot see the println result on console. can anyone
>>>>>> help? thank you!
>>>>>>
>>>>>> public class SimpleInterceptor extends AbstractInterceptor { public
>>>>>> String intercept(ActionInvocation invocation) throws Exception {
>>>>>> System.out.println("!!!!!SimpleInterceptor==date:" + (new Date())); return
>>>>>> invocation.invoke(); } }
>>>>>>
>>>>>> <?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"> <struts> <constant
>>>>>> name="struts.i18n.encoding" value="UTF-8"/> <constant
>>>>>> name="struts.devMode" value="false"/> <constant
>>>>>> name="struts.enable.DynamicMethodInvocation" value="false"/> <constant
>>>>>> name="struts.custom.i18n.resources" value="default"/> <constant
>>>>>> name="struts.serve.static.browserCache" value="true"/> <constant
>>>>>> name="struts.convention.action.suffix" value="Controller"/>
>>>>>> ?<constant name="struts.convention.action.mapAllMatches"
>>>>>> value="true"/> <constant
>>>>>> name="struts.convention.default.parent.package"
>>>>>> value="rest-default"/> <constant
>>>>>> name="struts.convention.package.locators" value="rest"/> <constant
>>>>>> name="struts.convention.result.path" value="/WEB-INF/content"/> <constant
>>>>>> name="struts.multipart.saveDir"
>>>>>> value="Z:\apacheroot\uploads"/> <constant
>>>>>> name="struts.multipart.maxSize" value="1024000"/> <package
>>>>>> name="default" namespace="/" extends="rest-default"> <interceptors>
>>>>>> <interceptor name="authentication"
>>>>>> class="com.xunan.framework.web.interceptor.SimpleInterceptor"/>
>>>>>> <interceptor-stack name="user"> <interceptor-ref
>>>>>> name="authentication"/> <interceptor-ref name="defaultStack"/>
>>>>>> </interceptor-stack> <interceptor-stack name="user-submit"> <interceptor-ref
>>>>>> name="tokenSession"/> <interceptor-ref name="user"/>
>>>>>> ?</interceptor-stack> <interceptor-stack name="guest"> <interceptor-ref
>>>>>> name="defaultStack"/> </interceptor-stack> </interceptors>
>>>>>> <default-interceptor-ref name="user"/> <global-results> <result name="error"
>>>>>> type="freemarker">/error.jsp</result> </global-results>
>>>>>> <global-exception-mappings> <exception-mapping
>>>>>> exception="java.lang.Exception" result="error"> </exception-mapping>
>>>>>> </global-exception-mappings> </package> <package name="main"
>>>>>> namespace="/post" extends="default"> <default-interceptor-ref
>>>>>> name="user"/> </package>
>>>>>>
>>>>>> <package name="admin" namespace="/admin" extends="default">
>>>>>> <default-interceptor-ref name="user"/> </package> </struts>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>--
>>>>"Hey you! Would you help me to carry the stone?" Pink Floyd
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>
>>
>>
>>
>>-- 
>>"Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>

Re:Re: Re: How to setup Interceptor when using struts2.1.6 rest plugin with convention

Posted by xnpeng <xn...@163.com>.
Hi,musachy!
   things are going on. when i add a line to my Controller(Action):
 
@InterceptorRefs({@InterceptorRef("user"), @InterceptorRef("defaultStack")})
public class MainController extends MainAction {...}
 
then some error happens:
Caused by: Unable to find interceptor class referenced by ref-name user - [unknown location]

again,the following is my config file.
 
<struts>
    <constant name="struts.i18n.encoding" value="UTF-8"/>
    <constant name="struts.devMode" value="false"/>
    <constant name="struts.enable.DynamicMethodInvocation" value="false"/>
    <constant name="struts.custom.i18n.resources" value="default"/>
    <constant name="struts.serve.static.browserCache" value="true"/>
    <constant name="struts.convention.action.suffix" value="Controller"/>
    <constant name="struts.convention.action.mapAllMatches" value="true"/>
    <constant name="struts.convention.default.parent.package" value="rest-default"/>
    <constant name="struts.convention.package.locators" value="rest"/>
    <constant name="struts.convention.result.path" value="/WEB-INF/content"/>
    <constant name="struts.multipart.saveDir" value="Z:\apacheroot\uploads"/>
    <constant name="struts.multipart.maxSize" value="1024000"/>
    <package name="default" namespace="/" extends="struts-default">
        <interceptors>
            <interceptor name="authentication"  class="com.xunan.framework.web.interceptor.SimpleInterceptor"/>
            <interceptor-stack name="user">
                <interceptor-ref name="authentication"/>
                <interceptor-ref name="defaultStack"/>
            </interceptor-stack>
            <interceptor-stack name="user-submit">
                <interceptor-ref name="tokenSession"/>
                <interceptor-ref name="user"/>
            </interceptor-stack>
            <interceptor-stack name="guest">
                <interceptor-ref name="defaultStack"/>
            </interceptor-stack>
        </interceptors>
        <default-interceptor-ref name="user"/>
        <global-results>
            <result name="error" type="freemarker">/error.jsp</result>
        </global-results>
        <global-exception-mappings>
            <exception-mapping exception="java.lang.Exception" result="error">
            </exception-mapping>
        </global-exception-mappings>
    </package>
    <package name="main" namespace="/post" extends="default">
        <interceptors>
            <interceptor name="authentication"  class="com.xunan.framework.web.interceptor.SimpleInterceptor"/>
            <interceptor-stack name="user">
                <interceptor-ref name="authentication"/>
                <interceptor-ref name="defaultStack"/>
            </interceptor-stack>
            <interceptor-stack name="user-submit">
                <interceptor-ref name="tokenSession"/>
                <interceptor-ref name="user"/>
            </interceptor-stack>
            <interceptor-stack name="guest">
                <interceptor-ref name="defaultStack"/>
            </interceptor-stack>
        </interceptors>
        <default-interceptor-ref name="user"/>
    </package>
    
    <package name="admin" namespace="/admin" extends="default">
        <default-interceptor-ref name="user"/>
    </package>
</struts>

 


在2009-05-28,"Musachy Barroso" <mu...@gmail.com> 写道:
>that setting is telling Convention to use that package for the actions
>it will create, and its default interceptor stack will be applied to
>those actions. You need to make it point to your own package, which
>defines a default interceptor stack with your interceptor. Either
>that, or use @InterceptorRef in your actions.
>
>musachy
>
>2009/5/27 xnpeng <xn...@163.com>:
>> hi,Musachy :
>>   I have a line defined in config file:
>> <constant name="struts.convention.default.parent.package" value="rest-default"/>
>>  do you mean change to otherwise?
>>
>>
>>
>>
>> 在2009-05-28,"Musachy Barroso" <mu...@gmail.com> 写道:
>>>also, change this:
>>>
>>><constant name="struts.convention.default.parent.package" value="rest-default"/>
>>>
>>>and make it point to your interceptor stack, otherwise your
>>>interceptor won't be used, unless you use the @InterceptorRef
>>>annotation.
>>>
>>>musachy
>>>
>>>On Wed, May 27, 2009 at 9:31 PM, Dave Newton <ne...@yahoo.com> wrote:
>>>> You're setting the default parent package to rest-default, which doesn't
>>>> include your interceptor--have you tried setting it to the package with
>>>> your interceptor in it?
>>>>
>>>> Dave
>>>>
>>>> xnpeng wrote:
>>>>>
>>>>> Hi, when i use rest-plugin with convention plugin in struts2.1.6, i
>>>>> cannot setup my interceptor. the following is my interceptor and
>>>>> config file. i cannot see the println result on console. can anyone
>>>>> help? thank you!
>>>>>
>>>>> public class SimpleInterceptor extends AbstractInterceptor { public
>>>>> String intercept(ActionInvocation invocation) throws Exception {
>>>>> System.out.println("!!!!!SimpleInterceptor==date:" + (new Date())); return
>>>>> invocation.invoke(); } }
>>>>>
>>>>> <?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"> <struts> <constant
>>>>> name="struts.i18n.encoding" value="UTF-8"/> <constant
>>>>> name="struts.devMode" value="false"/> <constant
>>>>> name="struts.enable.DynamicMethodInvocation" value="false"/> <constant
>>>>> name="struts.custom.i18n.resources" value="default"/> <constant
>>>>> name="struts.serve.static.browserCache" value="true"/> <constant
>>>>> name="struts.convention.action.suffix" value="Controller"/>
>>>>> ?<constant name="struts.convention.action.mapAllMatches"
>>>>> value="true"/> <constant
>>>>> name="struts.convention.default.parent.package"
>>>>> value="rest-default"/> <constant
>>>>> name="struts.convention.package.locators" value="rest"/> <constant
>>>>> name="struts.convention.result.path" value="/WEB-INF/content"/> <constant
>>>>> name="struts.multipart.saveDir"
>>>>> value="Z:\apacheroot\uploads"/> <constant
>>>>> name="struts.multipart.maxSize" value="1024000"/> <package
>>>>> name="default" namespace="/" extends="rest-default"> <interceptors>
>>>>> <interceptor name="authentication"
>>>>> class="com.xunan.framework.web.interceptor.SimpleInterceptor"/>
>>>>> <interceptor-stack name="user"> <interceptor-ref
>>>>> name="authentication"/> <interceptor-ref name="defaultStack"/>
>>>>> </interceptor-stack> <interceptor-stack name="user-submit"> <interceptor-ref
>>>>> name="tokenSession"/> <interceptor-ref name="user"/>
>>>>> ?</interceptor-stack> <interceptor-stack name="guest"> <interceptor-ref
>>>>> name="defaultStack"/> </interceptor-stack> </interceptors>
>>>>> <default-interceptor-ref name="user"/> <global-results> <result name="error"
>>>>> type="freemarker">/error.jsp</result> </global-results>
>>>>> <global-exception-mappings> <exception-mapping
>>>>> exception="java.lang.Exception" result="error"> </exception-mapping>
>>>>> </global-exception-mappings> </package> <package name="main"
>>>>> namespace="/post" extends="default"> <default-interceptor-ref
>>>>> name="user"/> </package>
>>>>>
>>>>> <package name="admin" namespace="/admin" extends="default">
>>>>> <default-interceptor-ref name="user"/> </package> </struts>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>>
>>>
>>>--
>>>"Hey you! Would you help me to carry the stone?" Pink Floyd
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: user-help@struts.apache.org
>>>
>>
>
>
>
>-- 
>"Hey you! Would you help me to carry the stone?" Pink Floyd
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

Re: Re: How to setup Interceptor when using struts2.1.6 rest plugin with convention

Posted by Musachy Barroso <mu...@gmail.com>.
that setting is telling Convention to use that package for the actions
it will create, and its default interceptor stack will be applied to
those actions. You need to make it point to your own package, which
defines a default interceptor stack with your interceptor. Either
that, or use @InterceptorRef in your actions.

musachy

2009/5/27 xnpeng <xn...@163.com>:
> hi,Musachy :
>   I have a line defined in config file:
> <constant name="struts.convention.default.parent.package" value="rest-default"/>
>  do you mean change to otherwise?
>
>
>
>
> 在2009-05-28,"Musachy Barroso" <mu...@gmail.com> 写道:
>>also, change this:
>>
>><constant name="struts.convention.default.parent.package" value="rest-default"/>
>>
>>and make it point to your interceptor stack, otherwise your
>>interceptor won't be used, unless you use the @InterceptorRef
>>annotation.
>>
>>musachy
>>
>>On Wed, May 27, 2009 at 9:31 PM, Dave Newton <ne...@yahoo.com> wrote:
>>> You're setting the default parent package to rest-default, which doesn't
>>> include your interceptor--have you tried setting it to the package with
>>> your interceptor in it?
>>>
>>> Dave
>>>
>>> xnpeng wrote:
>>>>
>>>> Hi, when i use rest-plugin with convention plugin in struts2.1.6, i
>>>> cannot setup my interceptor. the following is my interceptor and
>>>> config file. i cannot see the println result on console. can anyone
>>>> help? thank you!
>>>>
>>>> public class SimpleInterceptor extends AbstractInterceptor { public
>>>> String intercept(ActionInvocation invocation) throws Exception {
>>>> System.out.println("!!!!!SimpleInterceptor==date:" + (new Date())); return
>>>> invocation.invoke(); } }
>>>>
>>>> <?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"> <struts> <constant
>>>> name="struts.i18n.encoding" value="UTF-8"/> <constant
>>>> name="struts.devMode" value="false"/> <constant
>>>> name="struts.enable.DynamicMethodInvocation" value="false"/> <constant
>>>> name="struts.custom.i18n.resources" value="default"/> <constant
>>>> name="struts.serve.static.browserCache" value="true"/> <constant
>>>> name="struts.convention.action.suffix" value="Controller"/>
>>>> ?<constant name="struts.convention.action.mapAllMatches"
>>>> value="true"/> <constant
>>>> name="struts.convention.default.parent.package"
>>>> value="rest-default"/> <constant
>>>> name="struts.convention.package.locators" value="rest"/> <constant
>>>> name="struts.convention.result.path" value="/WEB-INF/content"/> <constant
>>>> name="struts.multipart.saveDir"
>>>> value="Z:\apacheroot\uploads"/> <constant
>>>> name="struts.multipart.maxSize" value="1024000"/> <package
>>>> name="default" namespace="/" extends="rest-default"> <interceptors>
>>>> <interceptor name="authentication"
>>>> class="com.xunan.framework.web.interceptor.SimpleInterceptor"/>
>>>> <interceptor-stack name="user"> <interceptor-ref
>>>> name="authentication"/> <interceptor-ref name="defaultStack"/>
>>>> </interceptor-stack> <interceptor-stack name="user-submit"> <interceptor-ref
>>>> name="tokenSession"/> <interceptor-ref name="user"/>
>>>> ?</interceptor-stack> <interceptor-stack name="guest"> <interceptor-ref
>>>> name="defaultStack"/> </interceptor-stack> </interceptors>
>>>> <default-interceptor-ref name="user"/> <global-results> <result name="error"
>>>> type="freemarker">/error.jsp</result> </global-results>
>>>> <global-exception-mappings> <exception-mapping
>>>> exception="java.lang.Exception" result="error"> </exception-mapping>
>>>> </global-exception-mappings> </package> <package name="main"
>>>> namespace="/post" extends="default"> <default-interceptor-ref
>>>> name="user"/> </package>
>>>>
>>>> <package name="admin" namespace="/admin" extends="default">
>>>> <default-interceptor-ref name="user"/> </package> </struts>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>>
>>--
>>"Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re:Re: How to setup Interceptor when using struts2.1.6 rest plugin with convention

Posted by xnpeng <xn...@163.com>.
hi,Musachy :
   I have a line defined in config file:
<constant name="struts.convention.default.parent.package" value="rest-default"/>
  do you mean change to otherwise?




在2009-05-28,"Musachy Barroso" <mu...@gmail.com> 写道:
>also, change this:
>
><constant name="struts.convention.default.parent.package" value="rest-default"/>
>
>and make it point to your interceptor stack, otherwise your
>interceptor won't be used, unless you use the @InterceptorRef
>annotation.
>
>musachy
>
>On Wed, May 27, 2009 at 9:31 PM, Dave Newton <ne...@yahoo.com> wrote:
>> You're setting the default parent package to rest-default, which doesn't
>> include your interceptor--have you tried setting it to the package with
>> your interceptor in it?
>>
>> Dave
>>
>> xnpeng wrote:
>>>
>>> Hi, when i use rest-plugin with convention plugin in struts2.1.6, i
>>> cannot setup my interceptor. the following is my interceptor and
>>> config file. i cannot see the println result on console. can anyone
>>> help? thank you!
>>>
>>> public class SimpleInterceptor extends AbstractInterceptor { public
>>> String intercept(ActionInvocation invocation) throws Exception {
>>> System.out.println("!!!!!SimpleInterceptor==date:" + (new Date())); return
>>> invocation.invoke(); } }
>>>
>>> <?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"> <struts> <constant
>>> name="struts.i18n.encoding" value="UTF-8"/> <constant
>>> name="struts.devMode" value="false"/> <constant
>>> name="struts.enable.DynamicMethodInvocation" value="false"/> <constant
>>> name="struts.custom.i18n.resources" value="default"/> <constant
>>> name="struts.serve.static.browserCache" value="true"/> <constant
>>> name="struts.convention.action.suffix" value="Controller"/>
>>> ?<constant name="struts.convention.action.mapAllMatches"
>>> value="true"/> <constant
>>> name="struts.convention.default.parent.package"
>>> value="rest-default"/> <constant
>>> name="struts.convention.package.locators" value="rest"/> <constant
>>> name="struts.convention.result.path" value="/WEB-INF/content"/> <constant
>>> name="struts.multipart.saveDir"
>>> value="Z:\apacheroot\uploads"/> <constant
>>> name="struts.multipart.maxSize" value="1024000"/> <package
>>> name="default" namespace="/" extends="rest-default"> <interceptors>
>>> <interceptor name="authentication"
>>> class="com.xunan.framework.web.interceptor.SimpleInterceptor"/>
>>> <interceptor-stack name="user"> <interceptor-ref
>>> name="authentication"/> <interceptor-ref name="defaultStack"/>
>>> </interceptor-stack> <interceptor-stack name="user-submit"> <interceptor-ref
>>> name="tokenSession"/> <interceptor-ref name="user"/>
>>> ?</interceptor-stack> <interceptor-stack name="guest"> <interceptor-ref
>>> name="defaultStack"/> </interceptor-stack> </interceptors>
>>> <default-interceptor-ref name="user"/> <global-results> <result name="error"
>>> type="freemarker">/error.jsp</result> </global-results>
>>> <global-exception-mappings> <exception-mapping
>>> exception="java.lang.Exception" result="error"> </exception-mapping>
>>> </global-exception-mappings> </package> <package name="main"
>>> namespace="/post" extends="default"> <default-interceptor-ref
>>> name="user"/> </package>
>>>
>>> <package name="admin" namespace="/admin" extends="default">
>>> <default-interceptor-ref name="user"/> </package> </struts>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
>
>-- 
>"Hey you! Would you help me to carry the stone?" Pink Floyd
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

Re: How to setup Interceptor when using struts2.1.6 rest plugin with convention

Posted by Musachy Barroso <mu...@gmail.com>.
also, change this:

<constant name="struts.convention.default.parent.package" value="rest-default"/>

and make it point to your interceptor stack, otherwise your
interceptor won't be used, unless you use the @InterceptorRef
annotation.

musachy

On Wed, May 27, 2009 at 9:31 PM, Dave Newton <ne...@yahoo.com> wrote:
> You're setting the default parent package to rest-default, which doesn't
> include your interceptor--have you tried setting it to the package with
> your interceptor in it?
>
> Dave
>
> xnpeng wrote:
>>
>> Hi, when i use rest-plugin with convention plugin in struts2.1.6, i
>> cannot setup my interceptor. the following is my interceptor and
>> config file. i cannot see the println result on console. can anyone
>> help? thank you!
>>
>> public class SimpleInterceptor extends AbstractInterceptor { public
>> String intercept(ActionInvocation invocation) throws Exception {
>> System.out.println("!!!!!SimpleInterceptor==date:" + (new Date())); return
>> invocation.invoke(); } }
>>
>> <?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"> <struts> <constant
>> name="struts.i18n.encoding" value="UTF-8"/> <constant
>> name="struts.devMode" value="false"/> <constant
>> name="struts.enable.DynamicMethodInvocation" value="false"/> <constant
>> name="struts.custom.i18n.resources" value="default"/> <constant
>> name="struts.serve.static.browserCache" value="true"/> <constant
>> name="struts.convention.action.suffix" value="Controller"/>
>>  <constant name="struts.convention.action.mapAllMatches"
>> value="true"/> <constant
>> name="struts.convention.default.parent.package"
>> value="rest-default"/> <constant
>> name="struts.convention.package.locators" value="rest"/> <constant
>> name="struts.convention.result.path" value="/WEB-INF/content"/> <constant
>> name="struts.multipart.saveDir"
>> value="Z:\apacheroot\uploads"/> <constant
>> name="struts.multipart.maxSize" value="1024000"/> <package
>> name="default" namespace="/" extends="rest-default"> <interceptors>
>> <interceptor name="authentication"
>> class="com.xunan.framework.web.interceptor.SimpleInterceptor"/>
>> <interceptor-stack name="user"> <interceptor-ref
>> name="authentication"/> <interceptor-ref name="defaultStack"/>
>> </interceptor-stack> <interceptor-stack name="user-submit"> <interceptor-ref
>> name="tokenSession"/> <interceptor-ref name="user"/>
>>  </interceptor-stack> <interceptor-stack name="guest"> <interceptor-ref
>> name="defaultStack"/> </interceptor-stack> </interceptors>
>> <default-interceptor-ref name="user"/> <global-results> <result name="error"
>> type="freemarker">/error.jsp</result> </global-results>
>> <global-exception-mappings> <exception-mapping
>> exception="java.lang.Exception" result="error"> </exception-mapping>
>> </global-exception-mappings> </package> <package name="main"
>> namespace="/post" extends="default"> <default-interceptor-ref
>> name="user"/> </package>
>>
>> <package name="admin" namespace="/admin" extends="default">
>> <default-interceptor-ref name="user"/> </package> </struts>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re:Re: How to setup Interceptor when using struts2.1.6 rest plugin with convention

Posted by xnpeng <xn...@163.com>.
Dave,
   I've tried set the config file to extends struts-default,also i've set in my packages,it still refuse to work.

    <package name="post" namespace="/post" extends="default">
        <interceptors>
            <interceptor name="authentication"  class="com.xunan.framework.web.interceptor.SimpleInterceptor"/>
            <interceptor-stack name="user">
                <interceptor-ref name="authentication"/>
                <interceptor-ref name="defaultStack"/>
            </interceptor-stack>
            <interceptor-stack name="user-submit">
                <interceptor-ref name="tokenSession"/>
                <interceptor-ref name="user"/>
            </interceptor-stack>
            <interceptor-stack name="guest">
                <interceptor-ref name="defaultStack"/>
            </interceptor-stack>
        </interceptors>
        <default-interceptor-ref name="user"/>
    </package>



在2009-05-28,"Dave Newton" <ne...@yahoo.com> 写道:
>You're setting the default parent package to rest-default, which doesn't
>include your interceptor--have you tried setting it to the package with
>your interceptor in it?
>
>Dave
>
>xnpeng wrote:
>> Hi, when i use rest-plugin with convention plugin in struts2.1.6, i
>> cannot setup my interceptor. the following is my interceptor and
>> config file. i cannot see the println result on console. can anyone
>> help? thank you!
>> 
>> public class SimpleInterceptor extends AbstractInterceptor { public
>> String intercept(ActionInvocation invocation) throws Exception { 
>> System.out.println("!!!!!SimpleInterceptor==date:" + (new Date())); 
>> return invocation.invoke(); } }
>> 
>> <?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"> <struts> <constant
>> name="struts.i18n.encoding" value="UTF-8"/> <constant
>> name="struts.devMode" value="false"/> <constant
>> name="struts.enable.DynamicMethodInvocation" value="false"/> 
>> <constant name="struts.custom.i18n.resources" value="default"/> 
>> <constant name="struts.serve.static.browserCache" value="true"/> 
>> <constant name="struts.convention.action.suffix" value="Controller"/>
>>  <constant name="struts.convention.action.mapAllMatches"
>> value="true"/> <constant
>> name="struts.convention.default.parent.package"
>> value="rest-default"/> <constant
>> name="struts.convention.package.locators" value="rest"/> <constant
>> name="struts.convention.result.path" value="/WEB-INF/content"/> 
>> <constant name="struts.multipart.saveDir"
>> value="Z:\apacheroot\uploads"/> <constant
>> name="struts.multipart.maxSize" value="1024000"/> <package
>> name="default" namespace="/" extends="rest-default"> <interceptors> 
>> <interceptor name="authentication"
>> class="com.xunan.framework.web.interceptor.SimpleInterceptor"/> 
>> <interceptor-stack name="user"> <interceptor-ref
>> name="authentication"/> <interceptor-ref name="defaultStack"/> 
>> </interceptor-stack> <interceptor-stack name="user-submit"> 
>> <interceptor-ref name="tokenSession"/> <interceptor-ref name="user"/>
>>  </interceptor-stack> <interceptor-stack name="guest"> 
>> <interceptor-ref name="defaultStack"/> </interceptor-stack> 
>> </interceptors> <default-interceptor-ref name="user"/> 
>> <global-results> <result name="error"
>> type="freemarker">/error.jsp</result> </global-results> 
>> <global-exception-mappings> <exception-mapping
>> exception="java.lang.Exception" result="error"> </exception-mapping> 
>> </global-exception-mappings> </package> <package name="main"
>> namespace="/post" extends="default"> <default-interceptor-ref
>> name="user"/> </package>
>> 
>> <package name="admin" namespace="/admin" extends="default"> 
>> <default-interceptor-ref name="user"/> </package> </struts>
>> 
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

Re: How to setup Interceptor when using struts2.1.6 rest plugin with convention

Posted by Dave Newton <ne...@yahoo.com>.
You're setting the default parent package to rest-default, which doesn't
include your interceptor--have you tried setting it to the package with
your interceptor in it?

Dave

xnpeng wrote:
> Hi, when i use rest-plugin with convention plugin in struts2.1.6, i
> cannot setup my interceptor. the following is my interceptor and
> config file. i cannot see the println result on console. can anyone
> help? thank you!
> 
> public class SimpleInterceptor extends AbstractInterceptor { public
> String intercept(ActionInvocation invocation) throws Exception { 
> System.out.println("!!!!!SimpleInterceptor==date:" + (new Date())); 
> return invocation.invoke(); } }
> 
> <?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"> <struts> <constant
> name="struts.i18n.encoding" value="UTF-8"/> <constant
> name="struts.devMode" value="false"/> <constant
> name="struts.enable.DynamicMethodInvocation" value="false"/> 
> <constant name="struts.custom.i18n.resources" value="default"/> 
> <constant name="struts.serve.static.browserCache" value="true"/> 
> <constant name="struts.convention.action.suffix" value="Controller"/>
>  <constant name="struts.convention.action.mapAllMatches"
> value="true"/> <constant
> name="struts.convention.default.parent.package"
> value="rest-default"/> <constant
> name="struts.convention.package.locators" value="rest"/> <constant
> name="struts.convention.result.path" value="/WEB-INF/content"/> 
> <constant name="struts.multipart.saveDir"
> value="Z:\apacheroot\uploads"/> <constant
> name="struts.multipart.maxSize" value="1024000"/> <package
> name="default" namespace="/" extends="rest-default"> <interceptors> 
> <interceptor name="authentication"
> class="com.xunan.framework.web.interceptor.SimpleInterceptor"/> 
> <interceptor-stack name="user"> <interceptor-ref
> name="authentication"/> <interceptor-ref name="defaultStack"/> 
> </interceptor-stack> <interceptor-stack name="user-submit"> 
> <interceptor-ref name="tokenSession"/> <interceptor-ref name="user"/>
>  </interceptor-stack> <interceptor-stack name="guest"> 
> <interceptor-ref name="defaultStack"/> </interceptor-stack> 
> </interceptors> <default-interceptor-ref name="user"/> 
> <global-results> <result name="error"
> type="freemarker">/error.jsp</result> </global-results> 
> <global-exception-mappings> <exception-mapping
> exception="java.lang.Exception" result="error"> </exception-mapping> 
> </global-exception-mappings> </package> <package name="main"
> namespace="/post" extends="default"> <default-interceptor-ref
> name="user"/> </package>
> 
> <package name="admin" namespace="/admin" extends="default"> 
> <default-interceptor-ref name="user"/> </package> </struts>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org