jsp单击按钮没反应

有时候button加了监听,但是运行后,发现单击没反应。上例子

Onclick=”test.jsp”

改为

οnclick=" window.location.href='MyJsp'"

注意单引号和双引号

用SSH2在搭一个网站,出现一个jsp页面无法跳转到action。 麻烦大家帮忙看看 [code="java"] <%@ page language="java" import="java.util.*" pageEncoding="gb2312"%> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>维护单资料</title> <link rel="stylesheet" type="text/css" href="../css/transport.css" /> <script type="text/javascript" src="../js/function.js"></script> </head> <body> <!--标题--> <div id="title"> <div id="font"> <div id="task"> 维护单资料 </div> </div> </div> <!--查询 <div id="query"> <form name="form1"> <div id="numbers">公司编号:<input type="text" name="t1" class="inputs"/></div> <div id="numbers">公司名称:<input type="text" name="t2" class="inputs"/> <input type="button" value="查 询" class="button" /></div> </form> </div>--> <div id="main"> <form name="form1" action="apply!insert.do" method="post"> <!--按钮--> <div id="buttons"> <div id="six"> <div id="niu"> <input type="button" value="返 回" class="button" onClick="javascript:window.location.href='Fmcf2050.jsp'" target="ab"> </div> <div id="niu"> <input type="button" value="提交" class="button"> </div> </div> </div> <!--分页--> <div id="pagination"> </div> <!--下面主体--> <div id="underside" style="height: expression(body . offsetHeight-80);"> <!--空白间隔--> <!--表格--> <div id="mostly"> <table width="200" border="1" id="table" class="tab"> <tr> <td width="30%" class="td_right"> 设备编号: </td> <td width="70%" class="td_left"> <input type="text" name="equipmentID"> </td> </tr> <tr> <td class="td_right"> 报修人员: </td> <td class="td_left"> <input type="text" name="client"> </td> </tr> <tr> <td class="td_right"> 报障时间: </td> <td class="td_left"> <input type="text" name="submitTime"> </td> </tr> <tr> <td class="td_right"> 报障部门: </td> <td class="td_left"> <select name="department"> <option value=""></option> <option value="chuyun"> 储运车间 </option> <option value="tieban"> 铁板车间 </option> <option value="duxin"> 镀锌车间 </option> <option value="tieta"> 铁塔车间 </option> <option value="gangguanta"> 钢管塔车间 </option> <option value="guanta"> 管塔二车间 </option> <option value="bangongshi"> 办公室 </option> <option value="renshi"> 人事部 </option> <option value="caiwu"> 财务部 </option> <option value="caigou"> 采购部 </option> <option value="yingxiao"> 营销部 </option> <option value="houqin"> 后勤部 </option> <option value="anjian"> 安监部 </option> <option value="zhiguan"> 质管部 </option> <option value="qiye"> 信息部 </option> <option value="shengchan"> 生产调度部 </option> <option value="jishu"> 技术设备部 </option> <option value="dangqun"> 党勤工作部 </option> <option value="qiye"> 企业管理部 </option> </select> </td> </tr> <tr> <td class="td_right"> 维护类型: </td> <td class="td_left"> <select name="repairType"> <option value=""></option> <option value="systemFailure"> 系统故障 </option> <option value="newLine"> 增加网线 </option> <option value="networkFailure"> 网络故障 </option> <option value="softwareFailure"> 软件故障 </option> <option value="softwareInstall"> 安装新软件 </option> <option value="printerFailure"> 打印机故障 </option> </select> </td> </tr> <tr> <td class="td_right"> 故障表征: </td> <td class="td_left"> <textarea name="mainContent" cols="1" rows="5" style="width: 200px;"></textarea> </td> </tr> </table> </div> </div> </form> </div> </body> </html> [/code] 对应的ApplyAction 代码是这样: [code="java"] package com.demo.struts2.actions; import java.util.ArrayList; import com.demo.hibernate.dao.ApplyDAO; import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionSupport; public class ApplyAction extends ActionSupport { private ApplyDAO applyDAO=new ApplyDAO(); // 这个bean属性前千万不能缺少; private int listID; private String client; private String name; private String department; private String deviceType; private String equipmentID; private String deviceModle; private String mainContent; private String repairType; private String submitTime; private String finishTime; private String repairman; private String isSigned; private boolean mark=true; public void isOK(String s){ } @Override public void validate() { // TODO Auto-generated method stub //申请进行维修要验证。 System.out.println("applyAction验证了"); } @Override public String execute() throws Exception { System.out.println("applyAction执行"); // TODO Auto-generated method stub if(this.mark==false){ return Action.INPUT; } return Action.SUCCESS; } public String insert(){ System.out.println("插入新的维修申请单"); ArrayList<String> list=new ArrayList<String> (); list.add(client); list.add(department); list.add(deviceType); list.add(equipmentID); list.add(deviceModle); list.add(mainContent); list.add(repairType); list.add(submitTime); list.add(repairman); list.add(isSigned); //当出现一个填写项为空就不行。 for(String s:list){ if(s.equals("")||s==null){ this.mark=false; break; }else{ System.out.println(s); } } if(!mark){ return Action.ERROR; } return ""; } public ApplyDAO getApplyDAO() { return applyDAO; } public void setApplyDAO(ApplyDAO applyDAO) { this.applyDAO = applyDAO; } public int getListID() { return listID; } public void setListID(int listID) { this.listID = listID; } public String getClient() { return client; } public void setClient(String client) { this.client = client; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDepartment() { return department; } public void setDepartment(String department) { this.department = department; } public String getDeviceType() { return deviceType; } public void setDeviceType(String deviceType) { this.deviceType = deviceType; } public String getEquipmentID() { return equipmentID; } public void setEquipmentID(String equipmentID) { this.equipmentID = equipmentID; } public String getDeviceModle() { return deviceModle; } public void setDeviceModle(String deviceModle) { this.deviceModle = deviceModle; } public String getMainContent() { return mainContent; } public void setMainContent(String mainContent) { this.mainContent = mainContent; } public String getRepairType() { return repairType; } public void setRepaitType(String repairType) { this.repairType = repairType; } public String getSubmitTime() { return submitTime; } public void setSubmitTime(String submitTime) { this.submitTime = submitTime; } public String getFinishTime() { return finishTime; } public void setFinishTime(String finishTime) { this.finishTime = finishTime; } public String getRepairman() { return repairman; } public void setRepairman(String repairman) { this.repairman = repairman; } public String getIsSigned() { return isSigned; } public void setIsSigned(String isSigned) { this.isSigned = isSigned; } } =[size=large][/size] [/code]
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页