zoukankan      html  css  js  c++  java
  • Struts 2 初步入门(二)

    Struts 2 动态方法调用

    1.在HelloWorldAction中添加两个新的方法如下:

      

    import com.opensymphony.xwork2.ActionSupport;

    public class HelloWorldAction extends ActionSupport{
    public String add(){
    return "add";
    }

    public String update(){
    return "update";
    }
    @Override
    public String execute() throws Exception {
    System.out.println("执行excute()");
    return SUCCESS;

    }
    }

    2.创建add.jsp和update.jsp
    3.在strut.xml中动态配置动态方法调用如下:
      
    <struts>
    <package name="default" namespace="/" extends="struts-default">
    <action name="hello_*" method="{1}" class ="com.imooc.action.HelloWorldAction">
    <result>/result.jsp</result>
    <result name="add">/{1}.jsp</result>
    <result name="update">/{1}.jsp</result>
    </action>


    </package>



    </struts>

    4.在浏览器中输入访问地址:http://localhost:8080/0408/hello_update.action
    http://localhost:8080/0408/hello_add.action
     
     
  • 相关阅读:
    (二)正反向代理
    (一)服务器架构详解
    斐波那契数列
    旋转数组的最小值
    23 入栈 出栈
    重建二叉树
    22 大端序和小端序
    反转单链表
    替换空格
    二维数组中的查找
  • 原文地址:https://www.cnblogs.com/aiyamoer/p/8762564.html
Copyright © 2011-2022 走看看