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奋斗的小蘑菇
  • 相关阅读:
    vi编辑器
    数据发送的三种方式
    发送文件的三种方式
    提交表单提示框确定取消 点取消不会刷新页面
    input value="值栈的值"
    值栈
    struts2文件上传突破2M限制
    jsp取不到值栈的值
    站群--插件--点击量
    Java WebService 简单实例
  • 原文地址:https://www.cnblogs.com/liyuchen/p/4881474.html
Copyright © 2011-2022 走看看