Note that there are some explanatory texts on larger screens.

plurals
  1. POIntegrating interceptor to web requests in spring 3.0
    primarykey
    data
    text
    <p>Currently I am working on a web project and using spring 3.0 with annotation bases controllers.</p> <ol> <li>I am trying to use intercept for login.</li> <li>No url can be directly hit but from login using interceptor.</li> </ol> <p>I am able to write an interceptor which won't let pass anyone to move into website without giving required parameters for login. But problem is that, remaining pages can also be accessed directly.</p> <p>I am sharing with you my servlet.xml</p> <p>I am also wondering why I have to defien URL mappings to get interceptor working, otherwise it goes into a unlimited loop.</p> <p>please help me out in solving this issue, if you have any working example for this requirement, then please share it too.</p> <p>Thank you in advance.</p> <p>springmvc-servlet.xml</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt; &lt;context:component-scan base-package="com.waqas.app.controller" /&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt; &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /&gt; &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt; &lt;property name="suffix" value=".jsp" /&gt; &lt;/bean&gt; &lt;bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt; &lt;property name="urlMap"&gt; &lt;map&gt; &lt;!-- --&gt; &lt;entry key="contacts.htm"&gt;&lt;ref bean="contactController" /&gt;&lt;/entry&gt; &lt;entry key="users.htm"&gt;&lt;ref bean="loginController" /&gt;&lt;/entry&gt; &lt;entry key="hello.htm"&gt;&lt;ref bean="helloController" /&gt;&lt;/entry&gt; &lt;/map&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean name="contactController" class="com.waqas.app.controller.ContactController" /&gt; &lt;bean name="helloController" class="com.waqas.app.controller.HelloWorldController" /&gt; &lt;bean name="loginController" class="com.waqas.app.controller.LoginController" /&gt; &lt;bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt; &lt;property name="interceptors"&gt; &lt;list&gt; &lt;ref bean="loginInterceptor"/&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="mappings"&gt; &lt;value&gt; *.htm=contactController &lt;/value&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="loginInterceptor" class="com.waqas.app.interceptor.LoginInterceptor"&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>index.html</p> <pre><code>&lt;%@ include file="/WEB-INF/jsp/include.jsp" %&gt; &lt;jsp:forward page="contacts.htm"&gt;&lt;/jsp:forward&gt; </code></pre> <p>i also want to apply this interceptor on sepcific URLs/url pattern.</p> <p>Looking forward to your reply.</p> <p>Kind Regards, qasibeat</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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