10

Servip sprinkler searches for a jsp page instead of calling a controller method

 2 years ago
source link: https://www.codesd.com/item/servip-sprinkler-searches-for-a-jsp-page-instead-of-calling-a-controller-method.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Servip sprinkler searches for a jsp page instead of calling a controller method

advertisements

Hi I am trying to authenticate the user but seems like its calling a jsp page instead of another controller mapping.

My dispatcher servlet is

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${database.driver}" />
    <property name="url" value="${database.url}" />
    <property name="username" value="${database.user}" />
    <property name="password" value="${database.password}" />
</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="annotatedClasses">
        <list>
            <value>com.beingjavaguys.domain.User</value>
            <value>com.beingjavaguys.domain.Chat</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
        </props>
    </property>
</bean>

<bean id="hibernateTransactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

My web.xml is

dispatcher org.springframework.web.servlet.DispatcherServlet 1

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

and my controller is

@RequestMapping(value="/authenticate",method=RequestMethod.POST)
    public ModelAndView getAuthenticateResult(@ModelAttribute("user") User user,
            BindingResult result) {
        if(userService.authenticate(user))
        {
            return new ModelAndView("/userList");
        }
        else{
        return new ModelAndView("Login");
        }
    }

@RequestMapping(value="/userList", method=RequestMethod.GET)
    public ModelAndView getUserList() {
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("chat", userService.getChat());
        return new ModelAndView("UserDetails", model);

    }

I am calling authenticate.html from my login file using POST method but my problem is this error

HTTP Status 404 - /Spring-hibernate-integration-helloworld/WEB-INF/view/userList.jsp

type Status report

message /Spring-hibernate-integration-helloworld/WEB-INF/view/userList.html.jsp

description The requested resource is not available.

Why is it searching for the jsp file instead of redirecting it to a controller method? But if i use redirect:/userList.html it works then.Whats the logic behind it?


If you return a string that is interpreted as a name of a view to render. The name of the view is passed no the a ViewResolver (in your case probably an InternalResourceViewResolver) which will generate an (internal) URL to forward to. In this case that will be a JSP.

Now the redirect: and forward: prefixes are 2 special cases. The redirect: will result in a client side redirect to that URL, which in turn will call your controller due to your configuration. A forward: is handled on the server side and not the client side.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK