zoukankan      html  css  js  c++  java
  • Action的搜索顺序(Struts2搜索Action的机制)

      当访问如下链接时,

    http://localhost:8080/struts2Demo/path1/path2/path3/LoginAction.action
    

      第一步:判断当前路径下action是否存在,如:path1/path2/path3/

      第二步:存在:则去访问相应的Action;不存在:检查上一级路径的package中是否存在action(直到默认的namespace,此处默认的namespace为"/"),重复第一步。
      第三步:如果没有则报错。

      文件清单:LoginAction、index.jsp、success.jsp、struts.xml、web.xml
          index.jsp
      
        <form action ="LoginAction.action" method ="post" >
                <input type= "submit" value ="测试" />
           </form>

      struts.xml

      <package name ="default" namespace ="/" extends ="struts-default" >
            <action name= "LoginAction" class="com.struts2.action.LoginAction" method ="execute" >
                <result name= "success">/success.jsp </result>
            </action>
        </package>

      LoginAction.java

      

    public class LoginAction extends ActionSupport{
         public String execute (){
                String result="success" ;
                return result ;
         }
    }

    **************************************************************************************************

      如若转载请注明出处,谢谢。By奋斗的小蘑菇

    by奋斗的小蘑菇
  • 相关阅读:
    音乐播放器
    滚动视图、定时器、分页控件的综合使用
    简易拼图
    IOS开发复习笔记(1)-OC基础知识
    64位matlab mex64位编译器解决方案
    LibSvm添加到Matlab
    code first 数据库无损迁移
    asp.net mvc4连接mysql
    自定义控件引用时候尺寸发生变化
    jquery 操作动态添加的元素
  • 原文地址:https://www.cnblogs.com/liyuchen/p/4881474.html
Copyright © 2011-2022 走看看