在這個jsp中,我使用了2個表單動作,一個保存角色(表:定義角色)和其他調用drop來自其他表格的列表(表格:solutionList)。我可以在單個jsp中使用休眠方式有多個表單動作(表單內部表單)
點擊提交後,它沒有做任何事情。
如果刪除此形式(solutionMaster.html)
即時得到bean類的這個錯誤「無效的屬性 'sMName'[com.mode; .definingrole]:Bean屬性 'sMName' 不是可讀或具有一個無效的getter方法:getter的返回類型是否與setter的參數類型相匹配?
是的,我知道原因,因爲列'sMName'不是定義角色表的一部分。與此
事情我想知道的是,
- 我們可以在窗體內創建窗體嗎?
2.沒有創建另一個表單,如何獲取其他表的列值來定義角色表?
請幫忙。
在此先感謝。
<div class="modal inmodal" id="myModalForRole" tabindex="-1"
role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated bounceInRight">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">×</span><span class="sr-only">Close</span>
</button>
<i class="fa fa-laptop modal-icon"></i>
<h4 class="modal-title">Define Role</h4>
</div>
<div class="modal-body">
<form:form action="newRoleDetails.html" method="post"
commandName="deftemp" id="deftemp">
<div class="row">
<div class="form-group">
<form:form action="solutionName.html" method="post"
commandName="soltemp" id="soltemp">
<div class="col-sm-6">
<label>Solutions*</label><br>
<form:select path="sMName" class="form-control"
id="sMName">
<form:option value="" label="--select--"></form:option>
<c:forEach var="solutionList" items="${solutionList}"
varStatus="loop">
<form:option value="${solutionList}"
label="${solutionList}">
</form:option>
</c:forEach>
</form:select>
</div>
</form:form>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-sm-6">
<label>Parent Role*</label><br>
<form:textarea path="ParentRole" id="ParentRole"
class="form-control" placeholder="Enter the Parent Role" />
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-sm-6">
<label>Sub Role*</label><br>
<form:textarea path="SubRole" id="SubRole"
class="form-control" placeholder="Enter the Child role" />
</div>
</div>
</div>
<br>
<br>
<div class="modal-footer">
<button type="button" class="btn btn-white"
data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Submit
</button>
</div>
</form:form>
</div>
型號:(solutionlist.java)
package com.model;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table (name="solutionlist")
public class solutionlist implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="solutionId",nullable = false,columnDefinition = "UNSIGNED INT(4)")
Integer solutionId;
@Column(name="solutionName")
String solutionName;
@Column(name="solutionOwner")
String solutionOwner;
@Column(name="ownerMailId")
String ownerMailId;
@Column(name="additionDate")
String additionDate;
public Integer getSolutionId() {
return solutionId;
}
public void setSolutionId(Integer solutionId) {
this.solutionId = solutionId;
}
public String getSolutionName() {
return solutionName;
}
public void setSolutionName(String solutionName) {
this.solutionName = solutionName;
}
public String getSolutionOwner() {
return solutionOwner;
}
public void setSolutionOwner(String solutionOwner) {
this.solutionOwner = solutionOwner;
}
public String getOwnerMailId() {
return ownerMailId;
}
public void setOwnerMailId(String ownerMailId) {
this.ownerMailId = ownerMailId;
}
public String getAdditionDate() {
return new SimpleDateFormat("yyyy-MM-dd HH-mm-ss.SSS")
.format(new Date());
}
public void setAdditionDate(String additionDate) {
this.additionDate = additionDate;
}
}
definingrole.java
package com.model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="definingrole")
public class definingrole implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="SNo")
Integer SNo;
@Column(name="Solutions")
String Solutions;
@Column(name="ParentRole")
String ParentRole;
@Column(name="SubRole")
String SubRole;
public Integer getSNo() {
return SNo;
}
public void setSNo(Integer sNo) {
SNo = sNo;
}
public String getSolutions() {
return Solutions;
}
public void setSolutions(String solutions) {
Solutions = solutions;
}
public String getParentRole() {
return ParentRole;
}
public void setParentRole(String parentRole) {
ParentRole = parentRole;
}
public String getSubRole() {
return SubRole;
}
public void setSubRole(String subRole) {
SubRole = subRole;
}
}
控制器:newRoleDetails.html
@RequestMapping(value=NEWROLEDETAILS_PATH)
public String newRoleDetails(Map<String, Object> model, definingrole value,solutionlist sol) throws Exception {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String name = auth.getName();
String nameOfUser=TemplateService.getEmpNameOfUser(name);
model.put("nameOfUser",nameOfUser);
String userid=loginService.getUserId();
String role=loginService.getRole();
TemplateService.newRoleDetails(value);
definingrole deftemp=new definingrole();
model.put("deftemp", deftemp);
solutionlist s = new solutionlist();
ArrayList<templateDetails> listOfTemplate=TemplateService.listTemplateDetails(role,userid);
model.put("listOfTemplate",listOfTemplate);
return TEMPLATESUMMARY;
}
控制器:solutionName.html
@RequestMapping("/solutionlist.html")
public String solutionName(Map<String, Object> model,solutionlist sol) throws Exception {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String name = auth.getName();
String nameOfUser=TemplateService.getEmpNameOfUser(name);
model.put("nameOfUser",nameOfUser);
solutionlist soltemp = new solutionlist();
model.put("soltemp", soltemp);
ArrayList<String> solutionList=TemplateService.getSolutionListForTemplate();
model.put("solutionList", solutionList);
return REDIRECT_TEMPLATESUMMARY_URL;
}
請幫助......這個代碼每天滯留..... :( –
請解釋一下你是什麼需要做什麼?給你的控制器和模型的細節。在內部形成形式沒有任何意義。看起來像你的情況是不是直線前進。你必須使周圍的一種方式。 – Zico
我不明白爲什麼點你需要爲'select'名單 – Zico