首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

struts2 在jsp的from表单交付失效,不进入action

2013-09-24 
struts2 在jsp的from表单提交失效,不进入action本帖最后由 ProgrammingPower 于 2013-09-22 13:02:17 编辑

struts2 在jsp的from表单提交失效,不进入action
本帖最后由 ProgrammingPower 于 2013-09-22 13:02:17 编辑 from头如下

<form action="/MyApply/startFlow.action" method="post">
我一点提交 浏览器不进入struts2的action 而是在浏览器地址栏显示一行这个
http://localhost:8080/MyApply/itheima/customer/process/startFlow.jsp?courseId=1&username=%E6%9B%B9%E5%AE%87

http://localhost:8080/MyApply/itheima/customer/process/startFlow.jsp是我这个from所在JSP的路径
后面是我提交的两个属性 courseid username  可是怎么一点击提交 不进入action   反而感觉跟GET提交了
直接跑到了浏览器上面了呢? 求大神

代码如下

<form action="/MyApply/startFlow.action" method="post">
    
    <table>
    <tr>
<td width="130px" align="right" height="45px">请选择您的意向课程:</td>
<td>

  <input type="radio" name="courseId" value="1" onBlur="checkCourse()">高数&nbsp;&nbsp;&nbsp;

  <input type="radio" name="courseId" value="3" onBlur="checkCourse()">数据结构&nbsp;&nbsp;&nbsp;

  <input type="radio" name="courseId" value="4" onBlur="checkCourse()">运筹学&nbsp;&nbsp;&nbsp;
<input type="hidden" name="username" value="${sessionScope.user.username}" /> 
  <span id="s1" style="color: red;padding-left: 10px;"></span>
</td>
</tr>
<tr>
<td colspan="2" height="80px;">
<div style="background:url('../../images/customer/pic_button01.gif') no-repeat left top;width:110px; height:42px; padding-left:10px;">
<input type="submit" value="提交" style="outline:0 none; border:0 none; background:url('../../images/customer/pic_button01.gif') no-repeat right top;width:120px; height:42px;font-size:20px;color:#FFF;font-weight: bold;cursor:hand" />
    </div>
</td>
</tr>
</table>
</form>



struts.xml文件内容如下

<package name="jbpm" namespace="/" extends="struts-default">
   <action name="startFlow" class="com.my.apply.action.FlowAction" method="startFlow">
   <result>/my/customer/process/applyIndex.jsp</result>
   <result name="repeat">/repeat.jsp</result>
   </action>

struts2 表单 jsp html
[解决办法]
namespace  MyApply
[解决办法]
我记得访问应该是action  name属性的值!方法名   不知道记错没!
[解决办法]
你form的action="/MyApply/startFlow.action"改成绝对路径action="http://localhost:8080/MyApply/startFlow.action"试试
[解决办法]
把/MyApply/startFlow.action写成startFlow.action 就行了  你structs 配置文件的Id是不是startFlow?
[解决办法]
你的nameapace 为/   , 把 MyApply 去掉试试
[解决办法]

引用:
Quote: 引用:

你的nameapace 为/   , 把 MyApply 去掉试试


都不行, 刚刚才发现,我故意胡写一通 在表单提交的action中 竟然不会404  依然和上述一样.,

这事为啥  

说明 from 中的action 根本就没起到作用. 

求解



可能你的配置文件写错了吧,从来没遇到过这种情况
[解决办法]
你的action类怎么写的?

热点排行