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