zoukankan      html  css  js  c++  java
  • 【Struts2复习知识点三】Action的配置

    具体视图的返回可以由用户自己定义的Action来决定
    具体的手段是根据返回的字符串找到对应的配置项,来决定视图的内容
    具体Action的实现可以是一个普通的java类,里面有public String execute方法即可
    或者实现Action接口
    不过最常用的是从ActionSupport继承,好处在于可以直接使用Struts2封装好的方法

    struts.xml

    View Code
    <constant name="struts.devMode" value="true" />
    <package name="front" extends="struts-default" namespace="/">
    <action name="index" class="com.bjsxt.struts2.front.action.IndexAction1">
    <result name="success">/ActionIntroduction.jsp</result>
    </action>
    </package>

    IndexAction1.java

    View Code
    public class IndexAction1 {
    public String execute() {
    return "success";
    }
    }

    IndexAction2.java

    View Code
    import com.opensymphony.xwork2.Action;

    public class IndexAction2 implements Action {
    @Override
    public String execute() {
    return "success";
    }
    }

    IndexAction3.java

    View Code
    import com.opensymphony.xwork2.ActionSupport;

    public class IndexAction3 extends ActionSupport {

    @Override
    public String execute() {
    return "success";
    }
    }



  • 相关阅读:
    python 根据数组生成图片
    c++ 字符串转数字
    python 迷宫问题
    JavaScript 判断是否为空
    JavaScript 字符串转数字(整数,浮点数,进制转换)
    c++ 珊格迷宫问题
    python eval的用法
    python pillow 处理图片
    c 结构体
    python pillow 绘制图片
  • 原文地址:https://www.cnblogs.com/surge/p/2362079.html
Copyright © 2011-2022 走看看