Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to combine java config and xml to integrate spring security in Spring 3.1?
    primarykey
    data
    text
    <p>I'm trying to integrate Spring security to my app which uses java config.</p> <p>Following the examples in the book Spring Security 3.1 I managed to get things working with the auto generated login page. But when I try to replace that with a custom page I get</p> <pre><code>No mapping found for HTTP request with URI [/myapp/login/form] </code></pre> <p>I have also noticed that while the book's example project's jsps can include urls like</p> <pre><code>"/resources/css/main.css" </code></pre> <p>they don't work in my app, instead I have to prefix them with "../"</p> <p>The difference is that my app uses java config also for the servlet mapping ("/") while the book's example uses web.xml (also "/")</p> <p>What could be the reason that my app cannot find /resources but ../resources and also fails to find the login page?</p> <p>my web.xml</p> <pre><code>&lt;display-name&gt;My Web Application&lt;/display-name&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigClass&lt;/param-name&gt; &lt;param-value&gt;com.myapp.config.AppInitializer&lt;/param-value&gt; &lt;/context-param&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt; /WEB-INF/spring/security.xml &lt;/param-value&gt; &lt;/context-param&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;filter&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; </code></pre> <p></p> <p>And the AppInitializer class:</p> <pre><code>public class AppInitializer implements WebApplicationInitializer { @Override public void onStartup(ServletContext context) throws ServletException { AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); root.register(ApplicationContext.class); ServletRegistration.Dynamic dispatcher = context.addServlet("dispatcher", new DispatcherServlet(root)); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/"); } } </code></pre> <p>The request mapping handlers etc. are defined in the ApplicationContext.class referred by the AppInitializer. They are the same as in the book's example.</p> <p>Also, the login.jsp is identical to the example project at the moment.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload