..
Bahar Görünüm tarayıcıda modeli oluşturmak için tasarlanmış birçok Çözümleyicisi vardır. Sadece 'o InternalResourceViewResolver Suppot Servlet ve JSP kim olduğunu analiz eder.
Aracılığıyla Daha önce gördüğümüz gibi her denetleyici görünüm çözücüler yoluyla çözümlenmesi bir görünümü mantıksal adını verir, bizim durumumuzda son görünüm JSP ise.
[Dispatcherservlet]-servlet.xml aşağıdaki satırları yapılandırmak için yeterli InternalResourceViewResolver:
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </ Fasulye>Bu yapılandırma sayesinde, denetleyici bir dize döndüğünüzde / yol / Çözümleyici gibi bizim sonuç jsp / WEB-INF/jsp/path/result.jsp bir ileri olacak gör. Bir yönlendirme yapmak gerekirse Invce, sadece dize geri kontrol "redirect" öneki. Bir kez Our View Çözümleyicisi yapılandırılmış, sadece Model denetleyici tarafından yapılmış veri işleyebilir.
Hepimiz etiketleri tam bir örneğe bakın:
@ Denetleyici
{Public class FormController
RequestMapping @ ("formExample")
public String viewForm (Model model) {
/ / Benim modeli fasulye Ekle
FormBean formBean FormBean = new ();
formBean.setHidden ("hiddenValue");
model.addAttribute ("formBean" formBean);
Koleksiyon <String> <String> onay kutularını = new ArrayList ();
checkBoxes.add ("1");
checkBoxes.add ("2");
checkBoxes.add ("3");
model.addAttribute ("CheckBox'ları" onay kutularını);
Koleksiyon <String> <String> Radiobutonlar = new ArrayList ();
radiobuttons.add ("1");
radiobuttons.add ("2");
radiobuttons.add ("3");
model.addAttribute ("Radiobutonlar" onay kutularını);
Toplama seçenekleri = new ArrayList <OptionForm> <OptionForm> ();
OptionForm seçenek1 = new OptionForm ();
option1.setLabel ("seçenek1");
option1.setValue ("1");
options.add (seçenek1);
OptionForm OptionForm opsiyonu2 = new ();
option2.setLabel ("opsiyonu2");
option2.setValue ("2");
options.add (opsiyonu2);
model.addAttribute ("seçenekleri", seçenekler);
/ / Görünümü çözümleyici Çağrı
"form / örnek" return;
}
@ (= "Submit" yöntemi = RequestMethod.POST değer) RequestMapping
public String viewForm (FormBean b) {
/ / Görünümü çözümleyici Çağrı
"form / ok" return;
}
}
formumuzu:
<form:form commandName="formBean" action="submit">
<p>
<form:label path="input"> giriş </ form: label>
<form:input path="input"/>
</ P>
<p>
<form:label path="check1"> Check1 </ form: label>
<form:checkbox path="check1"/>
</ P>
<p>
<form:label path="check2"> check2 </ form: label>
<form:checkbox path="check2" value="value1" label="value1"/>
<form:checkbox path="check2" value="value2" label="value2"/>
<form:checkbox path="check2" value="value3" label="value3"/>
</ P>
<p>
<form:label path="check3"> check3 </ form: label>
path="check3" value="check3"/> <form:checkbox
</ P>
<p>
<form:label path="checkboxes"> onay kutularını </ form: label>
path="checkboxes" items="${checkBoxes}"/> <form:checkboxes
</ P>
<p>
<form:label path="radiobutton"> radiobutton </ form: label>
<form:radiobutton path="radiobutton" value="radiobutton1" label="radiobutton1"/>
<form:radiobutton path="radiobutton" value="radiobutton2" label="radiobutton2"/>
</ P>
<p>
<form:label path="radiobuttons"> Radiobutonlar </ form: label>
<form:radiobuttons path="radiobuttons" items="${radiobuttons}"/>
</ P>
<p>
<form:label path="password"> şifre </ form: label>
<form:password path="password"/>
</ P>
<p>
<form:label path="select"> seçmek </ form: label>
<form:select path="select">
<form:option value="-1" label="-- select" />
<form:options items="${options}" itemLabel="label" itemValue="value" />
</ Form: select>
</ P>
<p>
<form:label path="textarea"> textarea </ form: label>
<form:textarea path="textarea"/>
</ P>
<p>
<form:label path="hidden"> </ form: label> gizli
<form:hidden path="hidden"/>
</ P>
<input type="submit" value="submit" />
</ Formu: form>
| |
Linux (Ders)
Açık kaynak sistemi komple rehberi. 49 € düşük. |
| |
PHP (Ders)
Dinamik Web siteleri oluşturmak için tam ders. 49 € düşük. |
| |
Ruby on Rails ve Ruby (Ders)
Ruby ve RoR ile yazılım ve Web uygulamaları oluşturun. En düşük € 39. |