3

I have a Spring MVC @Controller in a library project which my main project depends upon. I want to redirect to this from a controller in my main project. How can I do this?

I have a @Configuration in the library with an appropriate @ComponentScan. I tried both putting that @Configuration in my getServletConfigClasses() in my main ApplicationInitializer, and putting it in an @Import tag on my main @Configuration.

When I do a return "redirect:/whateverurl" with either configuration, I just see the redirect string in my browser. It doesn't actually do the redirect.

Luiggi Mendoza
  • 83,472
  • 15
  • 149
  • 315
Sam Jones
  • 1,230
  • 1
  • 12
  • 22
  • *When I do a return `"redirect:/whateverurl"` with either configuration, I just see the redirect string in my browser. It doesn't actually do the redirect.* The application indeed **does** the redirect, but seems like Spring cannot manage the URL by using your `@Controller`, thus you get this issue. Make sure this `@Controller` is initialized and registered for use. – Luiggi Mendoza Feb 02 '15 at 16:28
  • That's what I thought I was doing by annotating it with `@Controller`, making a `@Configuration` with appropriate `@ComponentScan`, then including that `@Configuration` in the two different ways I know of. Is there something more I need to do to register it? – Sam Jones Feb 02 '15 at 16:37

1 Answers1

0

Is the library a Jar file?

If so, while creating the jar, the directory entries need to be added.

I think this question may have the answer -

Auto-wiring annotations in classes from dependent jars

Thanks, Paul

Community
  • 1
  • 1
Paul John
  • 1,626
  • 1
  • 12
  • 15