Hi,
Currently I am working on a web project and using spring 3.0 with annotation bases controllers.
1. I am trying to use intercept for login.
2. No url can be directly hit but from login using interceptor.
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.
I am sharing with you my servlet.xml
I am also wondering why I have to defien URL mappings to get interceptor working, otherwise it goes into a unlimited loop.
please help me out in solving this issue, if you have any working example for this requirement, then please share it too.
Thank you in advance.
springmvc-servlet.xml
Code:<?xml version="1.0" encoding="UTF-8"?> <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"> <context:component-scan base-package="com.waqas.app.controller" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="urlMap"> <map> <!-- --> <entry key="contacts.htm"><ref bean="contactController" /></entry> <entry key="users.htm"><ref bean="loginController" /></entry> <entry key="hello.htm"><ref bean="helloController" /></entry> </map> </property> </bean> <bean name="contactController" class="com.waqas.app.controller.ContactController" /> <bean name="helloController" class="com.waqas.app.controller.HelloWorldController" /> <bean name="loginController" class="com.waqas.app.controller.LoginController" /> <bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="interceptors"> <list> <ref bean="loginInterceptor"/> </list> </property> <property name="mappings"> <value> *.htm=contactController </value> </property> </bean> <bean id="loginInterceptor" class="com.waqas.app.interceptor.LoginInterceptor"> </bean> </beans>
index.html
HTML Code:<%@ include file="/WEB-INF/jsp/include.jsp" %> <jsp:forward page="contacts.htm"></jsp:forward>


Reply With Quote
