HTTP 302 Moved Temporarily Struts

  1. Request Method:
    POST
  2. Status Code:
    302 Moved Temporarily


  1. Content-Length:
    0
  2. Date:
    Sun, 07 Dec 2014 15:23:19 GMT
  3. Location:
    http://inspiron:8080/GrandFieldRescue/login.html
  4. Server:
    Apache-Coyote/1.1


在做的一个SSH+Ajax项目,遇到了HTTP 302 的错误。可是,在MyEclipse的控制台那里没有错误信息输出。

接着,只能上网,百度、谷歌了好几遍,都没有找到相似的情形。

后来,只能慢慢的分析:


<!DOCTYPE html>
<html>
  <head>
    <title>MyHtml.html</title>
	
    <meta name="keywords" content="keyword1,keyword2,keyword3">
    <meta name="description" content="this is my page">
    <meta name="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

  </head>
  
  <body>
    <form id="form" class="form-horizontal" action="user/modifyteam.action" method="post">
                <div class="control-group">
                    <label class="control-label">救援队名称:</label>
                    <div class="controls">
                        <input type="text" class="input-normal control-text" data-rules="{required:true}" name="team.gName" >
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">队长/负责人:</label>
                    <div class="controls">
                        <input type="text" class="input-normal control-text" data-rules="{required : true}" name="team.principal" >
                    </div>
                </div>
            <div class="control-group">
                <label class="control-label">城市:</label>
                <div class="controls bui-form-group-select" data-type="city"   >
                    <select class="input-small" name="team.country" ><option>c</option></select>  
                    <select class="input-small" name="team.province" ><option>p</option></select>  
                    <select class="input-small" name="team.city" ><option>c</option></select>
                </div>
            </div>
                <div class="control-group">
                    <label class="control-label">创队时间:</label>
                    <div class="controls">
                        <input type="text" class="input-normal control-text" data-rules="{required : true}"  name="team.createTime" >
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">救援性质:</label>
                    <div class="controls">
                        <input type="text" class="input-normal control-text" data-rules="{required : true}"  name="team.property" >
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">地址:</label>
                    <div class="controls">
                        <input type="text" class="input-normal control-text" data-rules="{required : true}"  name="team.address" >
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">宗旨:</label>
                    <div class="controls">
                        <input type="text" class="input-normal control-text" data-rules="{required : true}"  name="team.tenet" >
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">上级单位:</label>
                    <div class="controls">
                        <input type="text" class="input-normal control-text" data-rules="{required : true}"  name="team.affiliation" >
                        <label class="checkbox"><input type="checkbox" value="flase" name="IsRegister" >是否民政注册</label>
                    </div>

                </div>
                <div class="control-group">
                    <label class="control-label">介绍:</label>
                    <div class="controls control-row4">
                        <textarea class="input-large" type="text" data-rules="{required : true}" name="team.presentation"></textarea>
                    </div>
                </div>
                 <div class="row actions-bar">
                <div class="form-actions span13 offset3">
                    <button type="submit" class="button button-primary">保存</button>
                    <button type="reset" class="button">重置</button>
                </div>
                 </div>
        </form>
  </body>
</html>


全部填了 1 之后,就出现HTTP 302错误了。

而后,将action里对应的team的属性的类型都改为String,就可以通过了。

也就是说,Struts会自动地将框里填的字符串转换为相应的类型;

若转换失败,浏览器会看到HTTP 302 Moved Temporarily,后台卡死。

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。