zoukankan      html  css  js  c++  java
  • Sturts2的action不执行任何方法的原因

    今天用<s:url action="xxx">调用action的时候出现了一个“异常”,

    action里的任何方法都没有执行,直接返回success,而且没有任何报错。

    struts2.xml

    1 <action name="toDeletePapper" class="deleteAction" method="toDeletePapper">
    2 <result name="success" >/success.html</result>
    3 <result name="input">/fail.html</result>
    4 </action>

    jsp

    1 <s:url action="toDeletePapper" id="Delete" >
    2 <s:param name="qid">
    3 <s:property value="qid"/>
    4 </s:param>

    action

     1 private IDeleteService deleteService;
     2     private Integer thisqid;
     3      public void setThisqid(Integer thisqid){
     4          this.thisqid = thisqid;
     5      }
     6      
     7     @Resource
     8     public void setDeleteService(IDeleteService deleteService) {
     9         this.deleteService = deleteService;
    10     }
    11         
    12     public String toDeletePapper()throws Exception
    13     {
    14         System.out.println(qidd);
    15     try {
    16         deleteService.deletePapper(qidd);
    17                     
    18             return SUCCESS;
    19             
    20         } catch (Exception e) {
    21             e.printStackTrace();
    22             System.out.println("error!");
    23             return INPUT;
    24         }
    25     }

    因为是用<s:url>的原因,起初我认为是spring没有配置好事务管理或者是哪个配置文件出了问题。

    再后来我认为是method没有写对,默认执行excute()的缘故。

    最后搜索到了解决问题的关键。

    一般情况下action不执行方法在Jsp页面有一下3种情况:

    1.视图页面是不是写的有问题

    2.有没有重名的name,即对象中有同名变量

    3.有没有用了不能直接赋值的变量名

     

  • 相关阅读:
    不能交易的物料不可做接收
    限制车间备料方式更改
    成本维护不允许超过设定比例
    车间不可操作非车间仓
    手工成本维护不可以将成本改为零
    手工成本维护超过1500元提醒
    成本查询
    同一供应商只能有一个有效的报价单
    新增报价单状态为有效状态
    同一供应商同一物料存在有效报价时不能再新增报价
  • 原文地址:https://www.cnblogs.com/liuxiaoke/p/3460536.html
Copyright © 2011-2022 走看看