SpringMVC——radiobuttons標簽


/FormTest/src/org/fkit/controller/UserController.java

@RequestMapping(value="radioform1" ,method=RequestMethod.GET)
    public String radioForm1(Model model) {
        User user = new User();
        user.setSex("男");
        model.addAttribute("user",user);
        List<String> sexList = new ArrayList<String>();
        sexList.add("男");
        sexList.add("女");
        model.addAttribute("sexList", sexList);
        return "content/radioForm1.jsp";
    }

/FormTest/WebContent/content/radioForm1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>radiobuttons</title>
</head>
<body>
    <form:form modelAttribute="user" method="post" action="">
        <table>
            <tr>
                <td>性別:</td>
                <td>
                  <form:radiobuttons path="sex" items="${sexList}"/>
                </td>
            </tr>
        </table>
    </form:form>
</body>
</html>

測試結果:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM