0

嗨,我想使用模型和视图重定向到 jsp 页面,但无法获取该页面。以下是任何人都可以帮助我的代码吗?

public ModelAndView login(HttpServletRequest request,
        HttpServletResponse response) throws GridException {
    ModelAndView mv = new ModelAndView("json view");
    Map map = new HashMap();
    GridMappingVO gridMappingVO=new GridMappingVO();
    String users = request.getParameter("username");
    String passwrd = request.getParameter("password");
    gridMappingVO.setUser(users);
    gridMappingVO.setPass(passwrd);
    List<GridMappingVO> searchList= gridMappingFacade.validate(gridMappingVO);
    if(users.equals(searchList.get(0).getUser()) && passwrd.equals(searchList.get(0).getPass())){
        System.out.println("validation succesfull");
        mv = new ModelAndView("searchResults");
        mv.addObject("searchList", searchList);

    }
    else{
        List<String> list = new ArrayList<String>();
        list.add("Invalid");
        map.put("error_messages", list);
        mv.addAllObjects(map);
    }





    return mv;

}

}

*这是使用 http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 的弹簧配置">

      <import resource="datasource-config.xml"/>
      <import resource="dao-config.xml"/>


<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">

    <property name="prefix">
        <value>/WEB-INF/jsp/</value>
    </property>

    <property name="suffix">
    <value>.jsp</value>
    </property>

</bean>
    <bean id="xmlFileViewResolver" class="org.springframework.web.servlet.view.XmlViewResolver">
        <property name="order" value="2" />
        <property name="location" value="/WEB-INF/views.xml" />
    </bean>

<bean name="/*.html" class="com.dashboard.web.controller.GridMappingController" scope="request">
    <property name="gridMappingFacade" ref="gridMappingFacade"/>
</bean> 

<bean id="gridMappingFacade" class="com.dashboard.web.application.GridMappingFacadeImpl">
    <property name="gridMappingService" ref="gridMappingService" />     
</bean>

<bean id="gridMappingService" class="com.dashboard.web.service.GridMappingServiceImpl">
    <property name="gridMappingRepository" ref="gridMappingRepository" />       
</bean> 

</beans>*
4

1 回答 1

0

使用此代码重定向页面

 mv.setViewName("searchResults");
于 2013-03-14T09:29:50.023 回答