return "/pages/front/success.jsp";
return "/pages/front/fail.jsp";
The structure of these two sentences is: prefix (prefix) + change value + suffix (suffix)
The prefix is/pages/front/. The suffix is. jsp
In the Springmvc.xml configuration file, the prefix suffix is configured with the view parser so that return has only the change value: Return "Success";
Springmvc.xml:
Hold down CTRL shift H, search for Internalresourceviewresolver, and then right-click Copy qualified name. Paste into the class.
<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "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-mv C-4.2.xsd Http://www.springframework.org/schema/context Http://www.springframework.org/schema/cont Ext/spring-context-4.2.xsd "> <!--Configure package Scan - <Context:component-scanBase-package= "Cn.java.controller"></Context:component-scan> <!--added SPRINGMVC-specific annotation drivers - <Mvc:annotation-driven></Mvc:annotation-driven> <!--View Resolver - <!--prefix: prefix - <!--suffix: suffix - <BeanID= "Internalresourceviewresolver"class= "Org.springframework.web.servlet.view.InternalResourceViewResolver"> < Propertyname= "prefix"value= "/pages/front/"></ Property> < Propertyname= "suffix"value= ". jsp"></ Property> </Bean> </Beans>
Java:
@RequestMapping (value= "test1") public String test1 (String username,string password) { if // Login Successful return "Success"; } Else // Logon Failure System.out.println (username); return "Fail"; } }
The real return here is/pages/front/success.jsp.
SPRINGMVC_ View parser and Chinese garbled problem