标签:can copy dmi oca 解析 AC pre amp drive
return "/pages/front/success.jsp";
return "/pages/front/fail.jsp";
这两句的结构是: 前缀(prefix)+变化值+ 后缀(suffix)
前缀是/pages/front/。后缀是.jsp
在springmvc.xml配置文件里用视图解析器配置前缀后缀,使return里只有变化值: return "success";
springmvc.xml:
按住ctrl shift h,搜索internalResourceViewResolver,然后右键copy qualified name。粘贴到class中。
<?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:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd "> <!-- 配置包扫描 --> <context:component-scan base-package="cn.java.controller"></context:component-scan> <!-- 加入springmvc特有的注解驱动 --> <mvc:annotation-driven></mvc:annotation-driven> <!-- 视图解析器 --> <!-- prefix:前缀--> <!-- suffix:后缀--> <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/pages/front/"></property> <property name="suffix" value=".jsp"></property> </bean> </beans>
java:
@RequestMapping(value="test1") public String test1(String username,String password) { if("admin".equals(username)&&"123".equals(password)) { //登录成功 return "success"; } else { //登录失败 System.out.println(username); return "fail"; } }
这里实际return的就是/pages/front/success.jsp
标签:can copy dmi oca 解析 AC pre amp drive
原文地址:https://www.cnblogs.com/lonske/p/9099767.html