1 配置多个解析时候,页面重定向报错404;
认真检查页面报错信息,是找不到/WEB-INF/jsp/htmlverifyok.html文件,实际在jsp目录下的文件名是verifyok.html,由此可以看出对spring mvc的视图解析用法理解错误;
如果前缀是/WEB-INF/jsp/,后缀是.jsp,setviewname的就是verifyok,这样才能找到文件;
忽略里面的判断,重点是setviewname的设置
@Controller
public class VerifyUserController {
@Resource
private UsersDao usersDao ;
@RequestMapping("/verify.do")
public ModelAndView verifyUser(HttpServletRequest req ) {
ModelAndView mv = new ModelAndView();
String user_name = "bobo";
if( user_name == "bobo") {
System.out.println("返回到html");
mv.setViewName("verifyok");
} else {
System.out.println("返回到html2");
mv.setViewName("html2");
}
return mv;
}
}
spring mvc的多视图解析处理
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".html"/>
<property name="viewNames" value="verifyok"></property>
<property name="order" value="1"></property>
</bean>
2 通过mybatis 的Mapper代理开发模式,实现对数据库的查询,与页面对比是否成功跳转
<select id="findUserAll" resultType="com.hlm.bo.Users">
select * from hlm_users
</select>