Results 1 to 5 of 5
  1. #1
    megabyte is offline Member
    Join Date
    Jan 2011
    Location
    Moscow
    Posts
    5
    Rep Power
    0

    Default Spring @RequestMapping and Error 400

    Hi. I wrote a Spring controller which should get requests from "login.htm" and "admin.htm" pages:

    Here is my controller:

    PHP Code:
    package vac.web.admin;
    
    import java.util.Properties;
    import javax.servlet.http.HttpServletRequest;
    import org.springframework.web.servlet.ModelAndView;
    import org.springframework.web.servlet.HandlerMapping;
    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;
    
    @Controller
    public class MainPage
    {
        private Properties properties;
    
        @Autowired
        public MainPage(Properties properties)
        {
            this.properties = properties;
        }
    
        @RequestMapping(value = {"login.htm", "admin.htm"})
        protected ModelAndView pageManager(@RequestParam("name") String name, HttpServletRequest request)
        {
            System.out.println("->" +
                    (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE));
    
            return new ModelAndView();
        }
    }
    And here is my dispatcher-servlet.xml:
    PHP 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:aop="http://www.springframework.org/schema/aop"
           xmlns:tx="http://www.springframework.org/schema/tx"
           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/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    
        <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
        <bean id="properties" class="java.util.Properties"/>
    
        <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="vac.web.admin" />
    
        <bean id="viewResolver"
              class="org.springframework.web.servlet.view.InternalResourceViewResolver"
              p:prefix="/WEB-INF/jsp/"
              p:suffix=".jsp" />
    </beans>
    Tomcat sent HTTP status 400 with a message "The request sent by the client was syntactically incorrect ()."

    Could somebody tell me what's wrong?

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    Hi.
    How you build and deploy your app?
    Skype: petrarsentev
    http://TrackStudio.com

  3. #3
    megabyte is offline Member
    Join Date
    Jan 2011
    Location
    Moscow
    Posts
    5
    Rep Power
    0

    Default

    I'm using NetBeans, so all work with deploying and building makes the IDE.

  4. #4
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    Then I think you have problem with configuration Tomcat and your IDE. I advice you to figure out how to build and to deploy your code without IDE.

    By the way Can you show full code?

    PS Do you really from Moscow?
    Skype: petrarsentev
    http://TrackStudio.com

  5. #5
    megabyte is offline Member
    Join Date
    Jan 2011
    Location
    Moscow
    Posts
    5
    Rep Power
    0

    Default

    Quote Originally Posted by Petr View Post
    Then I think you have problem with configuration Tomcat and your IDE. I advice you to figure out how to build and to deploy your code without IDE.

    By the way Can you show full code?
    Yes, but it has a lot of miscellaneous packages, what parts of code you want to see?

    PS Do you really from Moscow?
    Yeah :)

    btw, when I'm trying to use SimpleUrlHandlerMapping - it works perfectly:

    PHP 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:aop="http://www.springframework.org/schema/aop"
           xmlns:tx="http://www.springframework.org/schema/tx"
           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/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    
        <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
        <bean id="properties" class="java.util.Properties"/>
    
        <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <prop key="index.htm">indexController</prop>
                </props>
            </property>
        </bean>
    
        <bean name="indexController"
              class="org.springframework.web.servlet.mvc.ParameterizableViewController"
              p:viewName="index" />
    
        <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="vac.web.admin" />
    
        <bean id="viewResolver"
              class="org.springframework.web.servlet.view.InternalResourceViewResolver"
              p:prefix="/WEB-INF/jsp/"
              p:suffix=".jsp" />
    
    </beans>

Similar Threads

  1. Replies: 1
    Last Post: 12-27-2010, 05:21 PM
  2. Error while accessing a JSP page (Spring Framework)
    By new_coder in forum Web Frameworks
    Replies: 0
    Last Post: 12-15-2010, 04:14 PM
  3. Spring Configuration Error - XML issue?
    By hofsoc in forum New To Java
    Replies: 0
    Last Post: 09-20-2010, 03:21 PM
  4. Spring Mvc 404 error
    By jadeite100 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 01-04-2010, 06:38 AM
  5. Spring Mvc 404 error
    By jadeite100 in forum Web Frameworks
    Replies: 0
    Last Post: 01-04-2010, 06:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •