1 PackageMyTrain01;2 3 Public classcheckaction {4 String []hobbies;5 6 Publicstring[] Gethobbies () {7 8 returnHobbies;9 }Ten One Public voidsethobbies (string[] hobbies) { A This. Hobbies =Hobbies; - } - the PublicString Execute () { - return"Success"; - } -}
1 <%@ Page Language="Java"ContentType="text/html; Charset=utf-8"2 pageencoding="UTF-8"%>3 <%@ taglib Prefix="s"URI="/struts-tags" %>4 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">5 <HTML>6 <Head>7 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">8 <title>Insert Title here</title>9 </Head>Ten <Body> One <S:formMethod= "POST"Action= "/test01/check.action"> A <S:checkboxlabel= "read"name= "Hobbies"Fieldvalue= "read"></S:checkbox> - <S:checkboxlabel= "Music"name= "Hobbies"Fieldvalue= "Music"></S:checkbox> - <S:checkboxlabel= "Travel"name= "Hobbies"Fieldvalue= "Travel"></S:checkbox> the <S:checkboxlabel= "Painting"name= "Hobbies"Fieldvalue= "Painting"></S:checkbox> - <S:checkboxlabel= "Calligraphy"name= "Hobbies"Fieldvalue= "Calligraphy"></S:checkbox> - <S:submitvalue= "Submit"/> - </S:form> + </Body> - </HTML>
1 <%@ Page Language="Java"ContentType="text/html; Charset=utf-8"2 pageencoding="UTF-8"%>3 <%@ taglib Prefix="C"URI="Http://java.sun.com/jsp/jstl/core" %>4 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">5 <HTML>6 <Head>7 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">8 <title>Insert Title here</title>9 </Head>Ten <Body> One <C:foreachItems= "${hobbies}"var= "Ho"> A ${ho} - </C:foreach> - </Body> the </HTML>
1 <?XML version= "1.0" encoding= "UTF-8"?>2 3 <!DOCTYPE Struts public4 "-//apache software foundation//dtd Struts Configuration 2.0//en"5 "Http://struts.apache.org/dtds/struts-2.0.dtd">6 <Struts>7 < Packagename= "test01"namespace= "/test01"extends= "Struts-default">8 <Actionname= "Login_*"class= "Mytrain01.loginaction"Method= "{1}">9 <resultname= "Success">/user/success.jsp</result>Ten <resultname= "Error">/user/success.jsp</result> One </Action> A <Actionname= "Check"class= "Mytrain01.checkaction"Method= "Execute"> - <resultname= "Success">/testcheck.jsp</result> - </Action> the </ Package> - </Struts>
Use of the checkbox label