返回列表 发帖

[Struts] DMI

在struts2配置文件中加入 <constant name="struts.enable.DynamicMethodInvocation" value="true" />,可是还是无法使用DMI。      struts2-core-2.1.8.jar

        <script type="text/javascript">
                function regist()
                {
                        targetForm = document.forms[0];
                        targetForm.action = "logint!regist";
                }       
        </script>
  </head>  
  <body>         
          <form id="login" method="post" action="logint.action">
                  用户名:<input type="text" name="username"><br />
                  密  码:<input type="password" name="password"><br />
                  <input type="submit" value="登录">
                  <input type="submit" value="注册" onclick="regist();">
          </form>
  </body>

浏览器报错:The requested resource (/Struts2Test/logint!regist) is not available.

难道是BUG?

生命没有假期!
如果生命只剩下最后一秒,你可会想到我?

TOP

加上后缀.action后,运行成功!
同时发现:<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>,这个常量不配置,也是可以执行的。

<script type="text/javascript">
        function regist()
        {
            targetForm = document.forms[0];
            targetForm.action = "logint!regist.action";
        }   
</script>

李刚老师,感谢您的回复,一直在看疯狂系列,比那些翻译的书好多了。

TOP

原帖由 haho 于 2010-8-27 09:05 发表
加上后缀.action后,运行成功!
同时发现:,这个常量不配置,也是可以执行的。


        function regist()
        {
            targetForm = document.forms[0];
            targetForm.action = "logint!regist.action ...


:<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>不需要的
后缀.action也不需要加的,在LoginAction.java中加一个public String regist(){}的方法就可以了
倚楼听风雨,笑看江湖路。。。

TOP

原帖由 heyitang 于 2010-8-27 11:35 发表


:不需要的
后缀.action也不需要加的,在LoginAction.java中加一个public String regist(){}的方法就可以了


regist() 这个方法是有的,必须写成logint!regist.action 才能运行成功。否则浏览器报“The requested resource (/Struts2Test/logint!regist) is not available.

TOP

原帖由 haho 于 2010-8-27 11:52 发表


regist() 这个方法是有的,必须写成logint!regist.action 才能运行成功。否则浏览器报“The requested resource (/Struts2Test/logint!regist) is not available.”


哦,我不要加,用struts2.1版本是可以正常运行的!
难道是版本的原因?
倚楼听风雨,笑看江湖路。。。

TOP

返回列表