Sunday, 15 July 2012

spring - javax.servlet.ServletException: No adapter for handler [com.jitun.login]The DispatcherServlet configuration needs -



spring - javax.servlet.ServletException: No adapter for handler [com.jitun.login]The DispatcherServlet configuration needs -

i suvendu , facing difficulty while executing problem saying javax.servlet.servletexception: no adapter handler in next code.

my login controller class

bundle com.jitun.login.web; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestparam; import org.springframework.web.context.request.webrequest; import org.springframework.web.servlet.modelandview; import com.jitun.login.model.loginmodel; import com.jitun.login.service.loginservice; @controller @requestmapping("/login.spring") public class login { @autowired private loginservice loginservice; @autowired private loginmodel loginmodel; public void setloginservice(loginservice loginservice) { this.loginservice = loginservice; } public void setloginmodel(loginmodel loginmodel) { this.loginmodel = loginmodel; } public modelandview checkuser(httpservletrequest req,httpservletresponse res)throws exception{ string username=req.getparameter("uname"); string password=req.getparameter("pass"); loginmodel.setuname(username); loginmodel.setpass(password); boolean flag=loginservice.finduser(loginmodel); if(flag==true) homecoming new modelandview("/success.jsp"); homecoming new modelandview("/login.html"); } }

i made 2 spring config files applicationcontext-dao-jdbc.xml,applicationcontext-web.xml , follows

applicationcontext-dao-jdbc.xml--->

<?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:c="http://www.springframework.org/schema/c" xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> <context:component-scan base-package="com.jitun"></context:component-scan> <mvc:annotation-driven/> <bean class="org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter"/> <bean id="/login.spring" class="com.jitun.login.web.login" /> </beans>

applicationcontext-web.xml--->

<?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:c="http://www.springframework.org/schema/c" xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> <context:component-scan base-package="com.jitun"></context:component-scan> <mvc:annotation-driven/> <bean class="org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter"/> <bean id="/login.spring" class="com.jitun.login.web.login" /> </beans>

but while executing raises exception saying javax.servlet.servletexception: no adapter handler

i showing piece of code of exception

javax.servlet.servletexception: no adapter handler [com.jitun.login.web.login@157135]: dispatcherservlet configuration needs include handleradapter supports handler @ org.springframework.web.servlet.dispatcherservlet.gethandleradapter(dispatcherservlet.java:1128) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:903) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:856) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:936) @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:827) @ javax.servlet.http.httpservlet.service(httpservlet.java:621) @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:812) @ javax.servlet.http.httpservlet.service(httpservlet.java:722) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:225) @ org.apache.catalina.core.standardcontextvalve.__invoke(standardcontextvalve.java:169) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java)

and servlet config file is

<?xml version="1.0" encoding="utf-8"?> <servlet> <servlet-name>springdispatcherservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/applicationcontext-web.xml,/web-inf/applicationcontext-dao-jdbc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springdispatcherservlet</servlet-name> <url-pattern>*.spring</url-pattern> </servlet-mapping>

anyone can create me understand issue. confusing handleradapter issue. why need handleradapter in case (i.e while using annotation) .

spring

No comments:

Post a Comment