how to make form:checkboxes in JSP
2013-07-17 09:51
806 查看
retransmitTable.jsp file:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/retransmit_style.css"/>
<div>
<form:form modelAttribute="retrans" method="POST" action="/doRetransmition">
<fieldset>
<span>
<form:checkboxes items="${retransmitValues}" path="description" element="span class='label_check1'"/>
</span>
<input type="submit" name="Submit" id="Submit" value="Submit" class="button" />
</fieldset>
</form:form>
</div>
retransmit_style.css file:
fieldset { border: 0; padding-bottom: 9px; }
label
.radios {padding-top: 18px; background: url(divider.png) repeat-x 0 0; }
.label_check1{display: block; cursor: pointer; line-height: 20px; padding-bottom: 9px;}
.label_radio { margin-right: 5px; }
BgChechkController.java:
@RequestMapping(value = "/getRetransmitionTable", method = RequestMethod.GET)
public ModelAndView processSubmit(@ModelAttribute("retrans") Retransmition greeting, BindingResult result){
System.out.println("lei::getRetransmitionTable");
// FiscUser user = (FiscUser)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
// boolean showRetransmit = user.getUserDetails().hasRight(AccessRight.Code.VIEW_BGCHECK_DETAILS.name());
ModelAndView mav = new ModelAndView();
List<Retransmition> list = bgCheckDao.getAllRetransmit();
for(int i = 0; i < list.size(); i ++){
System.out.println(list.get(i).getDescription());
}
mav.addObject("retransmitValues", bgCheckDao.getAllRetransmit());
mav.addObject("retransmittable", greeting);
mav.setViewName("retransmitTable");
return mav;
}
@RequestMapping(value = "/doRetransmition", method = RequestMethod.POST)
public void doRetransmition(){
System.out.println("helloworld");
}
Retransmition.java:
package com.birdiinc.fisc.model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@EntityListeners({BaseEntityListener.class})
@Table(name = "RETRANSMIT_RIGHT")
public class Retransmition implements Serializable {
private String description;
@Id
@Column(name = "DESCRIPTION", nullable = false)
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public String toString() {
return this.getDescription();
}
}
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/retransmit_style.css"/>
<div>
<form:form modelAttribute="retrans" method="POST" action="/doRetransmition">
<fieldset>
<span>
<form:checkboxes items="${retransmitValues}" path="description" element="span class='label_check1'"/>
</span>
<input type="submit" name="Submit" id="Submit" value="Submit" class="button" />
</fieldset>
</form:form>
</div>
retransmit_style.css file:
fieldset { border: 0; padding-bottom: 9px; }
label
.radios {padding-top: 18px; background: url(divider.png) repeat-x 0 0; }
.label_check1{display: block; cursor: pointer; line-height: 20px; padding-bottom: 9px;}
.label_radio { margin-right: 5px; }
BgChechkController.java:
@RequestMapping(value = "/getRetransmitionTable", method = RequestMethod.GET)
public ModelAndView processSubmit(@ModelAttribute("retrans") Retransmition greeting, BindingResult result){
System.out.println("lei::getRetransmitionTable");
// FiscUser user = (FiscUser)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
// boolean showRetransmit = user.getUserDetails().hasRight(AccessRight.Code.VIEW_BGCHECK_DETAILS.name());
ModelAndView mav = new ModelAndView();
List<Retransmition> list = bgCheckDao.getAllRetransmit();
for(int i = 0; i < list.size(); i ++){
System.out.println(list.get(i).getDescription());
}
mav.addObject("retransmitValues", bgCheckDao.getAllRetransmit());
mav.addObject("retransmittable", greeting);
mav.setViewName("retransmitTable");
return mav;
}
@RequestMapping(value = "/doRetransmition", method = RequestMethod.POST)
public void doRetransmition(){
System.out.println("helloworld");
}
Retransmition.java:
package com.birdiinc.fisc.model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@EntityListeners({BaseEntityListener.class})
@Table(name = "RETRANSMIT_RIGHT")
public class Retransmition implements Serializable {
private String description;
@Id
@Column(name = "DESCRIPTION", nullable = false)
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public String toString() {
return this.getDescription();
}
}
相关文章推荐
- Spring Form Tags - How to use Text Box, Radio Button, Check Box and Drop Down List in Spring
- How to make Windows Form app truly Full Screen (and to hide Taskbar) in C#? 转
- How to retrieve checkboxes values in jQuery
- How to determine which checkboxes are checked in postback (sqlstr="delete spprod where id in ("&request("sid")&")")
- How to make our assemblies appeared in Add Reference dialog box
- How to check in your files in ADE
- How to collect TrustZone debug logs and check the meaning of error code in the logs
- How to make Office VBA code interact with a VSTO application-level add-in
- How to make windows access web server in VM linux OS
- How To Check Member In Window VS With CplusPlus?
- How to check number of Active connections in SQL server?
- 《笑傲股市 How to Make Money in Stocks》读书笔记
- How To Query Cross-Site Lists In DataFormWebPart
- How to make a bootroot.img in Bochs
- How to Create a Notify Icon in C# without a form
- How to Check if an Array Contains a Value in Java Efficiently?
- how to write your annotation types and make use of built-in annotations to control their behavior
- UIView Tutorial for iOS: How To Make a Custom UIView in iOS 5: A 5 Star Rating View
- How To Develop Login Form In Struts
- 码农如何快速打造一个有设计感的网站 How to Make Your Site Look Half-Decent in Half an Hour