十二 INPUT逻辑视图的配置

Action接口中提供了五个逻辑视图的名称

  • SUCCESS
  • ERROR
  • LOGIN
  • INPUT:input在某些拦截器会使用
  • NONE

配置逻辑视图:struts_demo2.xml,配置后出现错误信息会跳转到指定页面

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
 <package name="demo2" extends="struts-default" namespace="/">
  <global-results>
  <!-- 只要出错,回到当前页面 -->
  <result name="input">/demo2/demo1.jsp</result>
  </global-results>

  <action name="userAction1" class="com.itheima.struts2.demo2.UserAction1" method="">   
  </action>
   
 </package> 
          
</struts>

在JSP里输入类型错误的信息,比如年龄:

配置Input后跳转并显示错误信息:

猜你喜欢

转载自www.cnblogs.com/ltfxy/p/9826148.html