Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

madvoc add interceptor , @In @Out not work! #318

Closed
atjiu opened this issue Jun 18, 2016 · 2 comments
Closed

madvoc add interceptor , @In @Out not work! #318

atjiu opened this issue Jun 18, 2016 · 2 comments
Labels

Comments

@atjiu
Copy link

atjiu commented Jun 18, 2016

@InOut
Long id;
@Out String bookName;
@Action(value = "/book/${id}")
// @InterceptedBy(EchoInterceptor.class)
public String book() {
    System.out.println(id);
    bookName = "Java";
    return "#book";
}

http://localhost:8080/book/123 console print 123 and book.jsp render Java it work!

when i add EchoInterceptor

@InOut
Long id;
@Out String bookName;
@Action(value = "/book/${id}")
@InterceptedBy(EchoInterceptor.class)
public String book() {
    System.out.println(id);
    bookName = "Java";
    return "#book";
}

http://localhost:8080/book/123 console print null and book.jsp render nothing it not work!

why?

@igr
Copy link
Member

igr commented Jun 18, 2016

Check out the MadvocConfig class: https://github.com/oblac/jodd/blob/master/jodd-madvoc/src/main/java/jodd/madvoc/component/MadvocConfig.java#L66

By default, ServletConfigInterceptor is the one that those all the @In and @Out magic for you. When you specify the:

@InterceptedBy(EchoInterceptor.class)
public String book() {

you simply didn't use the ServletConfigInterceptor but just the echo one.

Fix

Either add the default configurator explicitly:

@InterceptedBy(EchoInterceptor.class, ServletConfigInterceptor.class)
public String book() {

OR specify all default ones

@InterceptedBy(EchoInterceptor.class, DefaultWebAppInterceptors.class)
public String book() {

OR add echo to default ones:

madvocConfig.setDefaultInterceptors(ew Class[] {EchoInterceptor.class, ServletConfigInterceptor.class};

OR do the same in madvoc.props

OR create new ActionInterceptorStack

and so on :)

@igr igr added the howto label Jun 18, 2016
@atjiu
Copy link
Author

atjiu commented Jun 18, 2016

There are so many methods to solve the problem

thank you very much!

@atjiu atjiu closed this as completed Jun 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants