当我点击“保存”按钮时,它应该转到我的控制器方法,但不是它给出了错误。 尝试搜索但无法解决问题。
请求映射
@RequestMapping(value = "/qualification", method = RequestMethod.POST)
public ModelAndView saveOrUpdate(ModelAndView model, HttpServletRequest req, HttpServletResponse res,
@ModelAttribute Qualification qualification, HttpSession session) {
System.out.println("Save");
System.out.println(qualification.getCompany());
return model;
}
qualification.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib prefix="tg" tagdir="/WEB-INF/tags"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<jsp:useBean id="pagedListHolder" scope="request" class="org.springframework.beans.support.PagedListHolder" />
<!-- Main Body Section Start -->
<main class="container padContnr">
<div class="row">
<div class="col-md-12">
<h1>Qualification Rules</h1>
</div>
</div>
<div class="bg-ltgreen padding-10 margin-t-10" id="QualSerch">
<form class="form-horizontal" action="#" method="#">
<div class="row">
<div class="col-sm-6 col-xs-12">
<div class="form-group">
<label class="label-bg col-xs-12">Company <span class="red">*</span></label>
<div class="col-xs-12">
<select class="form-control" name="company">
<option selected="selected">Select</option>
<option>Dell Inc.</option>
<option>Deutsche Bank AG Frankfurt</option>
<option>Disney Worldwide Services</option>
<option>Energy Future Holdings</option>
<option>HCL</option>
<option>Hewlett-Packard</option>
<option>Pepsico</option>
<option>Shire Pharmaceuticals Inc.</option>
<option>Skandia </option>
</select>
</div>
</div>
<div class="form-group">
<label class="label-bg col-xs-12">Class <span class="red">*</span></label>
<div class="col-xs-12">
<select class="form-control" name="class">
<option selected="selected">Select</option>
<option>Operating System</option>
<option>Computer System</option>
<option>EUC</option>
<option>Processor</option>
<option>Network Port</option>
<option>Disk Drive</option>
<option>Database Instance </option>
</select>
</div>
</div>
</div>
<div class="col-sm-6 col-xs-12">
<div class="form-group">
<label class="label-bg col-xs-12">Status <span class="red">*</span></label>
<div class="col-xs-12">
<select class="form-control" name="company">
<option selected="selected">Active</option>
<option>Inactive</option>
</select>
</div>
</div>
<div class="form-group">
<label class="label-bg col-xs-12">Rule <span class="red">*</span></label>
<div class="col-xs-12">
<input class="form-control" name="rule" type="text">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 text-c margin-t-10">
<button class="btn btn-primary btnSubmit" id="QualRule" type="button">GO</button>
</div>
</div>
</form>
</div>
<div id="QualRules" class="disNone">
<div class="row margin-t-10">
<div class="col-md-8 col-sm-8 col-xs-12">
<div class="f-size-16 display-inline-block float-l margin-r-20"> Items
<select class="small border-radius2 margin-l-10">
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</div>
<ul class="pagination margin-0 f-size-16 float-l">
<li class="page-item disabled"> <a class="page-link" href="#" aria-label="Previous"> <span aria-hidden="true">«</span> <span class="sr-only">Previous</span> </a> </li>
<li class="page-item"> <a class="page-link" href="#">1 <span class="sr-only">(current)</span></a> </li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item"><a class="page-link" href="#">4</a></li>
<li class="page-item"> <a class="page-link" href="#" aria-label="Next"> <span aria-hidden="true">»</span> <span class="sr-only">Next</span> </a> </li>
</ul>
</div>
<div class="col-md-4 col-sm-4 col-xs-12 flt-r padding-t-10"> <a href="Javascript:;" id="QualAdd" class="sprite add"></a> <a href="Javascript:;" id="EditBtn" class="sprite edit"></a> <a href="Javascript:;" id="Searchd" class="sprite search"></a> <a href="Javascript:;" id="DelBtn" class="sprite delete"></a> </div>
</div>
<!-- Table Details -->
<div class="table-responsive margin-t-10">
<table width="100%" border="0" class="table table-striped five trClick">
<thead>
<tr>
<th>Company</th>
<th>Class</th>
<th>Rule</th>
<th>Last Modified On</th>
<th>Last Modified By</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dell Inc.</td>
<td>Operating System</td>
<td>PEP_NE:QUAL_CS</td>
<td>5/6/2016 05:30:20</td>
<td>admin</td>
</tr>
<tr>
<td>Deutsche Bank AG Frankfurt</td>
<td>Computer System</td>
<td>PEP_NE:QUAL_NW</td>
<td>10/16/2015 15:40:32</td>
<td>admin</td>
</tr>
<tr>
<td>Disney Worldwide Services</td>
<td>EUC</td>
<td>EFH_NE:QUAL_CS</td>
<td>12/6/2015 12:23:41</td>
<td>admin</td>
</tr>
<tr>
<td>Energy Future Holdings</td>
<td>Processor</td>
<td>EFH_NE:QUAL_NW</td>
<td>11/26/2015 13:34:22</td>
<td>admin</td>
</tr>
</tbody>
</table>
</div>
<div class="row">
<div class="col-xs-12 text-c margin-t-10">
<button type="button" class="btn btn-default">Close</button>
</div>
</div>
</div>
<div class="bg-ltgreen padding-10 margin-t-10 disNone" id="QualEdit">
<form:form class="form-horizontal" action="qualification" modelAttribute="qualification" method="post" >
<div class="row">
<div class="col-sm-6 col-xs-12">
<div class="form-group">
<label class="label-bg col-xs-12">Company <span class="red">*</span></label>
<div class="col-xs-12">
<form:select id="company" class="form-control" path="company">
<form:option value="Select" />
<form:options items="${companyList}" itemValue="id" itemLabel="dropdownValue"/>
</form:select>
</div>
</div>
<div class="form-group">
<label class="label-bg col-xs-12">Class <span class="red">*</span></label>
<div class="col-xs-12">
<form:select id="companyClass" class="form-control" path="companyClass" onchange="switchOption();">
<form:option value="Select" />
<form:options items="${classList}" itemValue="id" itemLabel="dropdownValue"/>
</form:select>
</div>
</div>
</div>
<div class="col-sm-6 col-xs-12">
<div class="form-group">
<label class="label-bg col-xs-12">Status <span class="red">*</span></label>
<div class="col-xs-12">
<form:select path="status" class="form-control">
<form:options items="${statusList}" itemValue="id" itemLabel="dropdownValue" />
</form:select>
</div>
</div>
<div class="form-group">
<label class="label-bg col-xs-12">Rule <span class="red">*</span></label>
<div class="col-xs-12">
<form:input path="rule" class="form-control" type="text" />
</div>
</div>
</div>
</div>
<div id="QualAtt"class="row margin-t-10">
<div id="QualAtt1" class="col-md-6">
<!-- <table id="master_table" class="myAttr f-size-16">
<thead>
<tr>
<th> </th>
<th>Attribute</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><input class="checkBoxSize" type="checkbox"></td>
<td>Name </td>
<td><input name="System" class="form-control" type="text"></td>
</tr>
<tr>
<td><input class="checkBoxSize" type="checkbox"></td>
<td>Serial Number</td>
<td><input name="Instance" class="form-control" type="text"></td>
</tr>
<tr>
<td><input class="checkBoxSize" type="checkbox"></td>
<td>CPU Count</td>
<td><input name="Mainframe" class="form-control" type="text"></td>
</tr>
<tr>
<td><input class="checkBoxSize" type="checkbox"></td>
<td>RAM (MB)</td>
<td><input name="Mainframe" class="form-control" type="text"></td>
</tr>
<tr>
<td><input class="checkBoxSize" type="checkbox"></td>
<td>Operating System</td>
<td><input name="Mainframe" class="form-control" type="text"></td>
</tr>
<tr>
<td><input class="checkBoxSize" type="checkbox"></td>
<td>Is Virtual</td>
<td><input name="Mainframe" class="form-control" type="text"></td>
</tr>
</tbody>
</table> -->
</div>
</div>
<div class="row">
<div class="col-xs-12 margin-t-10">
<button class="btn btn-primary btnSubmit" type="submit" id="QualSav">Save</button>
<button class="btn btn-default btnCancel" type="button" id="QualCanl">Cancel</button>
</div>
</div>
</form:form>
</div>
</main>
资格模型
package com.hcl.ne.model;
public class Qualification {
private String company;
private String companyClass;
private String rule;
/* private String lastModifiedOn;
private String lastModifiedBy;*/
private String status;
private String[] attributeList;
private String attributeValue;
public String getAttributeValue() {
return attributeValue;
}
public void setAttributeValue(String attributeValue) {
this.attributeValue = attributeValue;
}
public String[] getAttributeList() {
return attributeList;
}
public void setAttributeList(String[] attributeList) {
this.attributeList = attributeList;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getCompanyClass() {
return companyClass;
}
public void setCompanyClass(String companyClass) {
this.companyClass = companyClass;
}
public String getRule() {
return rule;
}
public void setRule(String rule) {
this.rule = rule;
}
/* public String getLastModifiedOn() {
return lastModifiedOn;
}
public void setLastModifiedOn(String lastModifiedOn) {
this.lastModifiedOn = lastModifiedOn;
}
public String getLastModifiedBy() {
return lastModifiedBy;
}
public void setLastModifiedBy(String lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}*/
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
Plugin.js
/* Qualification Rule page */
$('#QualRule').on('click', function() {
$("#QualSerch").hide();
$("#QualRules").show();
});
$('#QualAdd').on('click', function() {
$("#QualEdit").show();
$("#QualRules").hide();
/* $("#QualAtt").show();*/
});
/*$('#QualSav, #QualCanl').on('click', function() {
$("#QualEdit").hide();
$("#QualRules").hide();
$("#QualSerch").show();
});
*/
function switchOption() {
var selectedValue= $("#companyClass").val();
$.ajax({
type: "GET",
url: "getClass",
data:'classId='+selectedValue,
success: function(data){
var tablebody = $('<tbody>');
var tablerow = "";
$(data.resultMenuForLocation).each(function(index){
tablerow = $('<tr>')
.append($('<td>').append($('<input>').attr({type :'checkbox'}).attr('class','checkBoxSize').attr({value : ''+$(this)[0].id}).attr('id','attributeList').attr('name','attributeList')))
.append($('<td>').append($(this)[0].dropdownValue+''))
.append($('<td>').append($('<input>').attr({type :'text'}).attr('class','form-control').attr('id','attributeValue').attr('name','attributeValue')))
$(tablebody).append(tablerow);
});
$('<table>')
.attr('id','master_table')
.attr('class','myAttr f-size-16')
.html('<thead><tr><th> </th><th>Attribute</th><th>Value</th></tr></thead>')
.append(tablebody)
.appendTo('div#QualAtt1');
}
});
}