zoukankan      html  css  js  c++  java
  • struts模式匹配

    假设前端代码:

     <a href="user/add.do?command=add">添加用户</a><br>
     <a href="user/del.do?command=del">删除用户</a><br>
     <a href="user/modify.do?command=modify">修改用户</a><br>

    模式匹配的过程:

    假设用户请求<a href="user/add.do?command=add">添加用户</a><br>
    那么会根据请求地址转到相应action的配置中,假设Action配置为:

    配置代码:

     <action path="/user/*"
        type="com.bjsxt.struts.UserAction"
        parameter="command" 
      >
       <!--
       <forward name="success" path="/user/{1}_success.jsp"/>
        -->
        <forward name="success" path="/{0}_success.jsp"/>
      </action>

    那么在此*对应的值为add,所以通配符{0}的值为add。同理也可在name中使用通配符

     <forward name="{0}_success" path="/{0}_success.jsp"/>

    Action代码:

    public class UserAction extends DispatchAction {

     public ActionForward add(ActionMapping mapping, ActionForm form,
       HttpServletRequest request, HttpServletResponse response)
       throws Exception {
      //return mapping.findForward("add_success");
      return mapping.findForward("success");
     }

     public ActionForward del(ActionMapping mapping, ActionForm form,
       HttpServletRequest request, HttpServletResponse response)
       throws Exception {
      //return mapping.findForward("del_success");
      return mapping.findForward("success");
     }

     public ActionForward modify(ActionMapping mapping, ActionForm form,
       HttpServletRequest request, HttpServletResponse response)
       throws Exception {
      //return mapping.findForward("modify_success");
      return mapping.findForward("success");
     }
     
     
    }

  • 相关阅读:
    Floyd_Warshall算法
    Bellman_Ford算法
    深度优先搜索
    广度优先搜索
    贪心算法_活动选择
    动态规划_0-1背包问题
    算法导论_动态规划_最长回文子序列
    算法导论_动态规划_最长公共子序列
    动态规划解决分割问题
    2016 Google中国开发者大会游记
  • 原文地址:https://www.cnblogs.com/jinzhengquan/p/1955233.html
Copyright © 2011-2022 走看看