Announcement Announcement Module
Collapse
No announcement yet.
Spring @RequestParam is not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring @RequestParam is not working

    Hi,

    I am a new to spring annotations.
    Security is working without any issue the main problem is while trying to access controller using RequestParam unable to detect where am I doing mistake. There are no error messages at the time if deployment,

    The following is my web.xml configuration.
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app>
    <display-name>XXY</display-name>
    	<context-param>
    		<param-name>log4jConfigLocation</param-name>
    		<param-value>classpath:xxy.properties</param-value>
    	</context-param>
    
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    
    	<listener>
    		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    	</listener>
    
    
    	<listener>
    		<listener-class>org.springframework.security.ui.session.HttpSessionEventPublisher</listener-class>
    	</listener>
    	
    	<servlet>
    		<servlet-name>xxy</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    <servlet-mapping>
    		<servlet-name>xxy</servlet-name>
    		<url-pattern>/*.html</url-pattern>
    	</servlet-mapping>
    <filter>
    		<filter-name>springSecurityFilterChain</filter-name>
    		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    	</filter>
    
    	<filter-mapping>
    		<filter-name>springSecurityFilterChain</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
    
    	<welcome-file-list>
    		<welcome-file>index.jsp</welcome-file>
    	</welcome-file-list>
    </web-app>
    The following is my xxy-servlet.xml file where have view's etc.

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans >
    
    	
    	<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
    
        <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
        
    	<context:annotation-config />
    	
    	<context:component-scan	base-package="com.apollo.xxy.web" />
    		
    	<bean id="viewResolver"
    		class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    		<property name="viewClass">
    			<value>org.springframework.web.servlet.view.JstlView</value>
    		</property>
    		<property name="prefix" value="/WEB-INF/secure/" />
    		<property name="suffix" value=".jsp" />
    	</bean>
    	
    	</beans>
    The controller code is as follows.

    Code:
    package com.apollo.xxy.web.issue;
    
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.servlet.ModelAndView;
    
    
    (at)Controller
    
    public class IssueController {
    	final Logger logger = LoggerFactory.getLogger(IssueController.class);
    	
    	(at)RequestMapping(value="/create/issue.html",method=RequestMethod.POST)
    	 public ModelAndView createIssue() 
    	 {
    		logger.debug("This is test");
    		return new ModelAndView("index");
    	 }
    }
    and my index.jsp (the very first page to access controller is as follows.

    Code:
    <%(aT) page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
    
    
    <html>
    	<head>
    		<base href="<%=basePath%>">
    		<title>First Page</title>
    	</head>
    	<body> 
    		This is my JSP page. 
    		<br>
    		<form action="create/issue.html" method="POST">
    			<input type="text" name="stuName" value=""/>
    			<input type="submit" value="Submit" />
    		</form>
    	</body>
    </html>
    As this is not allowing me to put the special char i am puttting (aT) instead.
    and also I didn't mention the URL's namespaces due to the same reason.
    In the log messages I also identified that when the IssueController and GenericController are being scanned for annotations surprisingly spring say's that there are URL path specified in the IssueController.
    Regards,
    Giridhar Duggirala
    Last edited by gduggirala; Sep 9th, 2008, 01:06 AM.

  • #2
    I think that u have to add following lines into u r xxy-servlet.xml
    <context:component-scan base-package="com.apollo.xxy.web.issue" />

    Comment


    • #3
      No change in the result

      Hi,

      Tried that but there is no change in the result.

      I also observed from the application log when compared with the working example is that in the working example it is able to identify the correct URL paths defined in the controller but in the my application log it is simply saying that there are no URL path identified so rejecting the bean

      the logs are given below.

      Not working log

      Code:
      [2008-09-09 11:01:47,566] (DefaultListableBeanFactory:383) - Creating instance of bean 'localeChangeInterceptor'
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultListableBeanFactory:457) - Eagerly caching bean 'localeChangeInterceptor' to allow for resolving potential circular references
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultListableBeanFactory:411) - Finished creating instance of bean 'localeChangeInterceptor'
      [DEBUG:main] [2008-09-09 11:01:47,566] (BeanUtils:382) - No property editor [[Ljava.lang.Object;Editor] found for type [Ljava.lang.Object; according to 'Editor' suffix convention
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:70) - Looking for URL mappings in application context: [email protected]1263b07: display name [WebApplicationContext for namespace 'xxy-servlet']; startup date [Tue Sep 09 11:01:47 MST 2008]; parent: [email protected]18c6982
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'org.springframework.context.annotation.internalPersistenceAnnotationProcessor': no URL paths identified
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'org.springframework.context.annotation.internalCommonAnnotationProcessor': no URL paths identified
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor': no URL paths identified
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'org.springframework.context.annotation.internalRequiredAnnotationProcessor': no URL paths identified
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'genericController': no URL paths identified
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'issueController': no URL paths identified
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': no URL paths identified
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0': no URL paths identified
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'viewResolver': no URL paths identified
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'messageSource': no URL paths identified
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'localeChangeInterceptor': no URL paths identified
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'localeResolver': no URL paths identified
      [DEBUG:main] [2008-09-09 11:01:47,566] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'applicationEventMulticaster': no URL paths identified
      Working log
      Code:
      [DEBUG:main] [2008-09-08 18:36:17,688] (DefaultListableBeanFactory:212) - Creating shared instance of singleton bean 'genericController'
      [DEBUG:main] [2008-09-08 18:36:17,688] (DefaultListableBeanFactory:383) - Creating instance of bean 'genericController'
      [DEBUG:main] [2008-09-08 18:36:17,688] (DefaultListableBeanFactory:457) - Eagerly caching bean 'genericController' to allow for resolving potential circular references
      [DEBUG:main] [2008-09-08 18:36:17,688] (DefaultListableBeanFactory:411) - Finished creating instance of bean 'genericController'
      [DEBUG:main] [2008-09-08 18:36:17,688] (DefaultAnnotationHandlerMapping:323) - Mapped URL path [/**/*.html] onto handler [org.springbyexample.web.servlet.mvc.simpleForm.GenericController@1f0f0c8]
      [DEBUG:main] [2008-09-08 18:36:17,688] (DefaultListableBeanFactory:212) - Creating shared instance of singleton bean 'personController'
      [DEBUG:main] [2008-09-08 18:36:17,688] (DefaultListableBeanFactory:383) - Creating instance of bean 'personController'
      [DEBUG:main] [2008-09-08 18:36:17,688] (InjectionMetadata:69) - Found injected field on class [org.springbyexample.web.servlet.mvc.simpleForm.PersonController]: AutowiredFieldElement for protected org.springbyexample.orm.hibernate3.annotation.dao.PersonDao org.springbyexample.web.servlet.mvc.simpleForm.PersonController.personDao
      [DEBUG:main] [2008-09-08 18:36:17,688] (DefaultListableBeanFactory:457) - Eagerly caching bean 'personController' to allow for resolving potential circular references
      [DEBUG:main] [2008-09-08 18:36:17,704] (InjectionMetadata:103) - Processing injected field of bean 'personController': AutowiredFieldElement for protected org.springbyexample.orm.hibernate3.annotation.dao.PersonDao org.springbyexample.web.servlet.mvc.simpleForm.PersonController.personDao
      [DEBUG:main] [2008-09-08 18:36:17,704] (DefaultListableBeanFactory:214) - Returning cached instance of singleton bean 'personDao'
      [DEBUG:main] [2008-09-08 18:36:17,704] (AutowiredAnnotationBeanPostProcessor:365) - Autowiring by type from bean name 'personController' to bean named 'personDao'
      [DEBUG:main] [2008-09-08 18:36:17,704] (DefaultListableBeanFactory:411) - Finished creating instance of bean 'personController'
      [DEBUG:main] [2008-09-08 18:36:17,704] (DefaultAnnotationHandlerMapping:323) - Mapped URL path [/save/person.html] onto handler [[email protected]20d6b7]
      [DEBUG:main] [2008-09-08 18:36:17,704] (DefaultListableBeanFactory:214) - Returning cached instance of singleton bean 'personController'
      [DEBUG:main] [2008-09-08 18:36:17,704] (DefaultAnnotationHandlerMapping:323) - Mapped URL path [/delete/person.html] onto handler [[email protected]20d6b7]
      [DEBUG:main] [2008-09-08 18:36:17,704] (DefaultListableBeanFactory:214) - Returning cached instance of singleton bean 'personController'
      [DEBUG:main] [2008-09-08 18:36:17,704] (DefaultAnnotationHandlerMapping:323) - Mapped URL path [/search/person.html] onto handler [[email protected]20d6b7]
      [DEBUG:main] [2008-09-08 18:36:17,704] (DefaultListableBeanFactory:214) - Returning cached instance of singleton bean 'personController'
      [DEBUG:main] [2008-09-08 18:36:17,704] (DefaultAnnotationHandlerMapping:323) - Mapped URL path [/form/person.html] onto handler [[email protected]20d6b7]
      [DEBUG:main] [2008-09-08 18:36:17,704] (DefaultListableBeanFactory:214) - Returning cached instance of singleton bean 'personController'
      [DEBUG:main] [2008-09-08 18:36:17,704] (DefaultAnnotationHandlerMapping:323) - Mapped URL path [/info/person.html] onto handler [[email protected]20d6b7]
      [DEBUG:main] [2008-09-08 18:36:17,719] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'tilesConfigurer': no URL paths identified
      [DEBUG:main] [2008-09-08 18:36:17,719] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'dynamicTilesViewResolver': no URL paths identified
      [DEBUG:main] [2008-09-08 18:36:17,719] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'messageSource': no URL paths identified
      [DEBUG:main] [2008-09-08 18:36:17,719] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'localeChangeInterceptor': no URL paths identified
      [DEBUG:main] [2008-09-08 18:36:17,719] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'localeResolver': no URL paths identified
      [DEBUG:main] [2008-09-08 18:36:17,719] (DefaultAnnotationHandlerMapping:86) - Rejected bean name 'applicationEventMulticaster': no URL paths identified

      Comment


      • #4
        did you try
        Code:
        <form action="/create/issue.html" method="POST">
        instead of
        Code:
        <form action="create/issue.html" method="POST">
        since your controller has that mapping?

        Comment


        • #5
          No change

          Hi there is still no change in the result. If you see the log file the "DefaultAnnotationHandlerMapping" is not mapping any URL while the application is not starting up.

          Any idea what is the root cause of this behavior?

          Regards,
          Giridhar Duggirala

          Comment


          • #6
            Can you change:
            Code:
            <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
            <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
            On
            Code:
            <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
                    <property name="alwaysUseFullPath" value="true"/>
            </bean>
            <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
                <property name="alwaysUseFullPath" value="true"/>
            </bean>
            After it if you persist config:
            Code:
            RequestMapping(value="/create/issue.html",method=RequestMethod.POST)
            Uri "/create/issue.html" should work (with post request)
            Last edited by mpetrashev; Oct 7th, 2008, 04:49 AM.

            Comment

            Working...
            X