指定多个配置文件-深入Struts2

xiaoxiao2021-02-28  18

一 配置方法     二 代码 1、helloworld.xml <? xml version = "1.0" encoding = "UTF-8" ?> <! DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" " http://struts.apache.org/dtds/struts-2.1.dtd" ; > < struts >          < package name = "default" namespace = "/" extends = "struts-default" >                  < action name = "*_*_*" method = "{2}" class = "com.cakin.{3}.{1}Action" >                          < result > /result.jsp </ result >                          < result name = "add" > /{2}. jsp </ result >                          < result name = "update" > /{2}. jsp </ result >                  </ action >          </ package > </ struts > 2、 struts.xml <? xml version = "1.0" encoding = "UTF-8" ?> <! DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" " http://struts.apache.org/dtds/struts-2.1.dtd" ; > < struts >          < include file = "helloworld.xml" ></ include >                   < constant name = "struts.enable.DynamicMethodInvocation" value = "false" ></ constant > </ struts > 3、Action类 package com.cakin.action;   import com.opensymphony.xwork2.ActionSupport;   public class HelloWorldAction extends ActionSupport {          @Override          public String execute() throws Exception {                 System. out .println( "执行Action" );                  return SUCCESS ;         }                   public String add()         {                  return "add" ;         }                   public String update()         {                  return "update" ;         } }   三 测试

 

  大小: 69.4 KB 大小: 19.6 KB 查看图片附件
转载请注明原文地址: https://www.6miu.com/read-2149957.html

最新回复(0)