csndsssss
2010-01-04 17:28 阅读 368
已采纳

struts2提交表单,没有执行action就直接返回input,请问怎么回事?

这是我的页面:
[code="java"]
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">





src='/flgl/dwr/interface/juserSelect.js'>
src='/flgl/dwr/interface/jgetLightningEvaluateLightningName.js'>
    <script type="text/javascript">
    function hideFocusWithButtons(){
        var buttons = document.getElementsByTagName('button');
        for(var i=0,l=buttons.length; i<l; i++){
            buttons[i].setAttribute('hidefocus',true);     //取消隐藏虚线, 把 hidefocus 设为 false 即可
        }
    }

    function bgChange(){
     var lis= document.getElementsByTagName('tr');
     for(var i=0; i<lis.length; i+=2)
     lis[i].style.background = '#F0FFFF';
    }

    function showDiv(){
        var d=document.getElementById('d');
        d.style.display="block";
    }

    function closeDiv(){
        var d=document.getElementById('d');
        d.style.display="none";
    }
    function loadLightningCheckUser(){
 document.getElementById("evaluateOperator").options.length=0;
 document.getElementById("checkOperator").options.length=0;
juserSelect.getUserSelect(callBackloadLightningCheckUser);

}
function callBackloadLightningCheckUser(data){
for(var i=0;i var varItem=new Option(data[i].empName,data[i].empName);
var varItem1=new Option(data[i].empName,data[i].empName);
if(varItem.value==""){
varItem.selected=true;
}
if(varItem1.value=="<%=request.getAttribute("checkOperator")%>"){
varItem1.selected=true;
}

       document.getElementById("evaluateOperator").options.add(varItem);
       document.getElementById("checkOperator").options.add(varItem1);
   }

}

function loadLightningName(){
document.getElementById("buildingName").options.add(new Option("--请选择建筑物名称--","0"));
var id=${requestScope.lightningEvaluateAppyFind.id};
jgetLightningEvaluateLightningName.getLightningEvaluateLightningName(id,callBackloadLightningName);
}

function callBackloadLightningName(data){

for(var i=0;i<data.length;i++){
  var varItem=new Option(data[i],data[i]);
  if(varItem.value=="<%=request.getAttribute("bulidingName")%>"){
   varItem.selected=true;
  }
  document.getElementById("buildingName").options.add(varItem);
}

}

function loadLightningLevel(){
var lightningLevle=document.getElementById("lightningCheckLevel");
for(var i=0;i if(lightningLevle[i].value==""){
lightningLevle[i].selected=true;
}
}
}

<body
    onload="bgChange();hideFocusWithButtons();loadLightningCheckUser();loadLightningName();loadLightningLevel();lao();"
    style="margin: 0px; margin-top: 0px; font-size: 12px; margin-left: 0px;">
    <s:if test="hasActionMessages()">
        <s:iterator value="actionMessages">
            <script language="JavaScript">   
            alert("<s:property escape="false"/>");
        </script>
        </s:iterator>
    </s:if>
    <div class="divBorder">
        <div
            style="width: 100%; background-image: url(/flgl/images/right_table_bg.jpg); margin: 0px; color: #333333; height: 25px; vertical-align: baseline; text-align: left">
            &nbsp;&nbsp;&nbsp;当前位置:技术评价&gt;防雷设计评价&gt;&gt;&gt;
        </div>
        <br />
        <br />
        <table width="100%" align="center">
            <s:form action="getLightningEvaluateByIdAndBuildingName" method="post" theme="simple" id="dd">
                <tr>
                    <td align="left" width="35%">
                        建筑单位名:<s:property value="%{#request.lightningEvaluateAppyFind.buildDepartmentName}"/>
                        <s:hidden name="buildingDepartmentId"
                            value="%{#request.lightningEvaluateAppyFind.id}"></s:hidden>
                    <td align="left" width="40%">
                        <select id="buildingName" name="buildingName">
                        </select>
                    </td>

                    <td>
                        <s:submit value="查询"></s:submit>
                    </td>
                </tr>
            </s:form>
        </table>

        <hr />

        <table width="100%">
            <s:form action="addLightningEvaluate" method="post" theme="simple">
                <tr>
                    <td>
                        建筑物名称
                    </td>
                    <td>
                        <s:textfield name="lightningEvaluate.lightningName"
                            value="%{#request.lightningEvaluateFind.lightningName}"></s:textfield>
                    </td>
                    <td>
                        建筑物地址
                    </td>
                    <td>
                        <s:textfield name="lightningEvaluate.lightningAddress"
                            value="%{#request.lightningEvaluateFind.lightningAddress}"></s:textfield>
                    </td>
                </tr>
                <tr align="center">
                    <td width="8%" align="left">
                        防雷分类
                    </td>
                    <td align="left">
                        <select id="lightningCheckLevel" name="lightningLevel">
                            <option value="1">
                                一类
                            </option>
                            <option value="2">
                                二类
                            </option>
                            <option value="3">
                                三类
                            </option>
                        </select>
                    </td>
                    <td width="11%" align="left">
                        建筑物高度
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.lightningHigh"
                            value="%{#request.lightningEvaluateFind.lightningHigh}"></s:textfield>
                    </td>

                    <td width="9%" align="left">
                        建筑物面积
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.lightningArea"
                            value="%{#request.lightningEvaluateFind.lightningArea}"></s:textfield>
                    </td>
                    <td width="8%" align="left">
                        建筑物层数
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.lightningLayer"
                            value="%{#request.lightningEvaluateFind.lightningLayer}"></s:textfield>
                    </td>
                </tr>
                <tr>

                    <td>
                        建筑物结构
                    </td>
                    <td>
                        <s:textfield name="lightningEvaluate.lightningStruct"
                            value="%{#request.lightningEvaluateFind.lightningStruct}"></s:textfield>
                    </td>

                    <td width="6%" align="left">
                        基础深度
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.StructDeep"
                            value="%{#request.lightningEvaluateFind.StructDeep}"></s:textfield>
                    </td>
                    <td width="6%" align="left">
                        设计接地电阻
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.designValue"
                            value="%{#request.lightningEvaluateFind.designValue}"></s:textfield>
                    </td>
                    <td>
                        电梯数
                    </td>
                    <td>
                        <s:textfield name="lightningEvaluate.liftNum"
                            value="%{#request.lightningEvaluateFind.liftNum}"></s:textfield>
                    </td>
                </tr>
                <tr>


                    <td width="6%" align="left">
                        单元数
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.unitNum"
                            value="%{#request.lightningEvaluateFind.unitNum}"></s:textfield>
                    </td>
                    <td width="6%" align="left">
                        电源情况
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.powerType"
                            value="%{#request.lightningEvaluateFind.powerType}"></s:textfield>
                    </td>
                    <td>
                        避雷带规格
                    </td>
                    <td>
                        <s:textfield name="lightningEvaluate.receivingSpec"
                            value="%{#request.lightningEvaluateFind.receivingSpec}"></s:textfield>
                    </td>
                    <td width="6%" align="left">
                        引下线规格
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.leadSpec"
                            value="%{#request.lightningEvaluateFind.leadSpec}"></s:textfield>
                    </td>
                </tr>
                <tr>

                    <td width="6%" align="left">
                        网格尺寸
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.receivingGrid"
                            value="%{#request.lightningEvaluateFind.receivingGrid}"></s:textfield>
                    </td>
                    <td>
                        引下线最大间距
                    </td>
                    <td>
                        <s:textfield name="lightningEvaluate.leadSpace"
                            value="%{#request.lightningEvaluateFind.leadSpace}"></s:textfield>
                    </td>

                    <td width="6%" align="left">
                        避雷带铺设
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.receivingStatus"
                            value="%{#request.lightningEvaluateFind.receivingStatus}"></s:textfield>
                    </td>
                    <td width="6%" align="left">
                        引下线铺设
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.leadStatus"
                            value="%{#request.lightningEvaluateFind.leadStatus}"></s:textfield>
                    </td>
                </tr>
                <tr>

                    <td>
                        等电位设计
                    </td>
                    <td>
                        <s:textfield name="lightningEvaluate.mebStatus"
                            value="%{#request.lightningEvaluateFind.mebStatus}"></s:textfield>
                    </td>

                    <td width="6%" align="left">
                        均压环设计
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.equalizerStatus"
                            value="%{#request.lightningEvaluateFind.equalizerStatus}"></s:textfield>
                    </td>
                    <td width="6%" align="left">
                        设计单位
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.designDepartment"
                            value="%{#request.lightningEvaluateFind.designDepartment}"></s:textfield>

                    </td>
                    <td>
                        图纸工号
                    </td>
                    <td>
                        <s:textfield name="lightningEvaluate.designPaper"
                            value="%{#request.lightningEvaluateFind.designPaper}"></s:textfield>
                    </td>
                </tr>
                <tr>


                    <td width="6%" align="left">
                        评价日期
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.evaluateDate"
                            value="%{#request.lightningEvaluateFind.designPaper}"></s:textfield>
                    </td>
                    <td width="6%" align="left">
                        审查编号
                    </td>

                    <td align="left">
                        <s:textfield name="lightningEvaluate.bh"
                            value="%{#request.lightningEvaluateFind.bh}"></s:textfield>
                    </td>
                    <td>
                        审核人
                    </td>
                    <td>
                        <select id="evaluateOperator" name="evaluateOperator"></select>
                    </td>
                    <td>
                        复核人
                    </td>
                    <td>
                        <select id="checkOperator" name="checkOperator"></select>
                    </td>
                </tr>
                <tr>
                    <td width="30%">
                        一、直接雷击设计评价
                    </td>
                    <td align="center">
                        <br>
                    </td>
                </tr>
                <tr>
                    <td colspan="8">
                        <s:textarea name="lightningEvaluate.evaluateZjl"
                            value="%{#request.lightningEvaluateFind.evaluateZjl}"></s:textarea>
                    </td>
                </tr>
                <tr>
                    <td>
                        二、侧击雷击设计评价
                    </td>
                    <td align="center">
                        <br>
                    </td>
                </tr>
                <tr>
                    <td colspan="8">
                        <s:textarea name="lightningEvaluate.evaluateCjl"
                            value="%{#request.lightningEvaluateFind.evaluateCjl}"></s:textarea>
                    </td>
                </tr>
                <tr>
                    <td>
                        三、雷电感应设计评价
                    </td>
                    <td align="center">
                        <br>
                    </td>
                </tr>
                <tr>
                    <td colspan="8">
                        <s:textarea name="lightningEvaluate.evaluateLdgy"
                            value="%{#request.lightningEvaluateFind.evaluateLdgy}"></s:textarea>
                    </td>
                </tr>
                <tr>
                    <td>
                        四、雷电波侵入设计评价
                    </td>
                    <td align="center">
                        <br>
                    </td>
                </tr>
                <tr>
                    <td colspan="8">
                        <s:textarea name="lightningEvaluate.evaluateLdbqr"
                            value="%{#request.lightningEvaluateFind.evaluateLdbqr}"></s:textarea>
                    </td>
                </tr>
                <tr>
                    <td>
                        五、其他设计评价
                    </td>
                    <td align="center">
                        <br>
                    </td>
                </tr>
                <tr>
                    <td colspan="8">
                        <s:textarea name="lightningEvaluate.evaluateQt"
                            value="%{#request.lightningEvaluateFind.evaluateQt}"></s:textarea>
                    </td>
                </tr>

                <tr align="center">
                    <td colspan="2">
                        <s:hidden name="evaluateId" value="%{#request.lightningEvaluateFind.id}"></s:hidden>
                        <s:submit value="保存" onclick="lao(dd);"></s:submit>
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                        <input type="button" hidefocus="true" value="重置"/>
                    </td>
                </tr>
            </s:form>
        </table>
    </div>
</body>


这是我的action:
public String addLightningEvaluate() {
System.out.println("++++++++++++++++++++++++++++");
if (null == ServletActionContext.getRequest().getParameter("evaluateId")
|| "".equals(ServletActionContext.getRequest().getParameter(
"evaluateId"))) {
lightningEvaluate.setCheckOperator(ServletActionContext
.getRequest().getParameter("checkOperator"));
lightningEvaluate.setEvaluateOperator(ServletActionContext
.getRequest().getParameter("evaluateOperator"));
lightningEvaluate.setLightningLevel(ServletActionContext
.getRequest().getParameter("lightningLevel"));
lightningEvaluate
.setTLightningEvaluateApply(lightningEvaluateService
.getBuildingDepartmentById(this.getBuildDepartmentId()));
if (lightningEvaluateService
.addLightningEvaluate(lightningEvaluate)) {
this.addActionMessage("添加技术评定书成功");
return SUCCESS;
} else {
this.addActionMessage("添加技术评定书失败");
return INPUT;
}
} else {
lightningEvaluate.setId(Integer.parseInt(ServletActionContext
.getRequest().getParameter("evaluateId")));
lightningEvaluate.setCheckOperator(ServletActionContext
.getRequest().getParameter("checkOperator"));
lightningEvaluate.setEvaluateOperator(ServletActionContext
.getRequest().getParameter("evaluateOperator"));
lightningEvaluate.setLightningLevel(ServletActionContext
.getRequest().getParameter("lightningLevel"));
lightningEvaluate
.setTLightningEvaluateApply(lightningEvaluateService
.getBuildingDepartmentById(this.getBuildDepartmentId()));
if (lightningEvaluateService
.updateLightningEvaluate(lightningEvaluate)) {
this.addActionMessage("添加技术评定书成功");
return SUCCESS;
} else {
this.addActionMessage("添加技术评定书失败");
return INPUT;
}
}
}
这个action执行添加和更新两个操作,添加可以,更新就不行。直接返回input,没有任何异常信息
[/code]

[b]问题补充:[/b]
连action方法都不进,我在action里打印了一句话,都不输出。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    weixin_42519818 weixin_42519818 2010-01-04 18:03

    你看看update的时候 else 的代码是否运行了。
    再看看你传给lightningEvaluateService.updateLightningEvaluate()的对象是否成功更新。

    点赞 评论 复制链接分享

相关推荐