📄 ajax的dwr框架 - - javaeye技术网站.htm
字号:
</SPAN>
<LI class=alt><SPAN> } </SPAN>
<LI class=""><SPAN> </SPAN>
<LI class=alt><SPAN> </SPAN><SPAN
class=keyword>public</SPAN><SPAN> </SPAN><SPAN
class=keyword>int</SPAN><SPAN> getBedrooms() { </SPAN>
<LI
class=""><SPAN> </SPAN><SPAN
class=keyword>return</SPAN><SPAN> bedrooms; </SPAN>
<LI class=alt><SPAN> } </SPAN>
<LI class=""><SPAN> </SPAN>
<LI class=alt><SPAN> </SPAN><SPAN
class=keyword>public</SPAN><SPAN> </SPAN><SPAN
class=keyword>void</SPAN><SPAN> setBedrooms(</SPAN><SPAN
class=keyword>int</SPAN><SPAN> bedrooms) { </SPAN>
<LI
class=""><SPAN> </SPAN><SPAN
class=keyword>this</SPAN><SPAN>.bedrooms = bedrooms;
</SPAN>
<LI class=alt><SPAN> } </SPAN>
<LI class=""><SPAN> </SPAN>
<LI class=alt><SPAN> </SPAN><SPAN
class=keyword>public</SPAN><SPAN> String getCity() {
</SPAN>
<LI
class=""><SPAN> </SPAN><SPAN
class=keyword>return</SPAN><SPAN> city; </SPAN>
<LI class=alt><SPAN> } </SPAN>
<LI class=""><SPAN> </SPAN>
<LI class=alt><SPAN> </SPAN><SPAN
class=keyword>public</SPAN><SPAN> </SPAN><SPAN
class=keyword>void</SPAN><SPAN> setCity(String city) {
</SPAN>
<LI
class=""><SPAN> </SPAN><SPAN
class=keyword>this</SPAN><SPAN>.city = city; </SPAN>
<LI class=alt><SPAN> } </SPAN>
<LI class=""><SPAN> </SPAN>
<LI class=alt><SPAN> </SPAN><SPAN
class=keyword>public</SPAN><SPAN> </SPAN><SPAN
class=keyword>int</SPAN><SPAN> getPrice() { </SPAN>
<LI
class=""><SPAN> </SPAN><SPAN
class=keyword>return</SPAN><SPAN> price; </SPAN>
<LI class=alt><SPAN> } </SPAN>
<LI class=""><SPAN> </SPAN>
<LI class=alt><SPAN> </SPAN><SPAN
class=keyword>public</SPAN><SPAN> </SPAN><SPAN
class=keyword>void</SPAN><SPAN> setPrice(</SPAN><SPAN
class=keyword>int</SPAN><SPAN> price) { </SPAN>
<LI
class=""><SPAN> </SPAN><SPAN
class=keyword>this</SPAN><SPAN>.price = price; </SPAN>
<LI class=alt><SPAN> } </SPAN>
<LI class=""><SPAN> </SPAN>
<LI class=alt><SPAN> </SPAN><SPAN
class=keyword>public</SPAN><SPAN> String getProvince() {
</SPAN>
<LI
class=""><SPAN> </SPAN><SPAN
class=keyword>return</SPAN><SPAN> province; </SPAN>
<LI class=alt><SPAN> } </SPAN>
<LI class=""><SPAN> </SPAN>
<LI class=alt><SPAN> </SPAN><SPAN
class=keyword>public</SPAN><SPAN> </SPAN><SPAN
class=keyword>void</SPAN><SPAN> setProvince(String province) {
</SPAN>
<LI
class=""><SPAN> </SPAN><SPAN
class=keyword>this</SPAN><SPAN>.province = province;
</SPAN>
<LI class=alt><SPAN> } </SPAN>
<LI class=""><SPAN>} </SPAN> </LI></OL></DIV>
<P> </P>
<DIV class=code_title>java 代码
<DIV class=dp-highlighter>
<DIV class=bar></DIV>
<OL class=dp-j>
<LI class=alt><SPAN><SPAN
class=keyword>package</SPAN><SPAN> ajax.dwr.simpledwr;
</SPAN></SPAN>
<LI class=""><SPAN> </SPAN>
<LI class=alt><SPAN></SPAN><SPAN
class=keyword>import</SPAN><SPAN> java.util.ArrayList;
</SPAN>
<LI class=""><SPAN></SPAN><SPAN
class=keyword>import</SPAN><SPAN> java.util.List; </SPAN>
<LI class=alt><SPAN> </SPAN>
<LI class=""><SPAN></SPAN><SPAN
class=keyword>public</SPAN><SPAN> </SPAN><SPAN
class=keyword>class</SPAN><SPAN> ApartmentDAO { </SPAN>
<LI class=alt><SPAN> </SPAN>
<LI class=""><SPAN> </SPAN><SPAN
class=keyword>public</SPAN><SPAN> List findApartments(</SPAN><SPAN
class=keyword>int</SPAN><SPAN> bedrooms, </SPAN><SPAN
class=keyword>int</SPAN><SPAN> bathrooms, </SPAN><SPAN
class=keyword>int</SPAN><SPAN> price) { </SPAN>
<LI
class=alt><SPAN> List list = findList(bedrooms, bathrooms, price);
</SPAN>
<LI
class=""><SPAN> </SPAN><SPAN
class=keyword>return</SPAN><SPAN> list; </SPAN>
<LI class=alt><SPAN> } </SPAN>
<LI class=""><SPAN> </SPAN>
<LI class=alt><SPAN> </SPAN>
<LI class=""><SPAN> </SPAN><SPAN
class=keyword>public</SPAN><SPAN> </SPAN><SPAN
class=keyword>int</SPAN><SPAN> countApartments(</SPAN><SPAN
class=keyword>int</SPAN><SPAN> bedrooms, </SPAN><SPAN
class=keyword>int</SPAN><SPAN> bathrooms, </SPAN><SPAN
class=keyword>int</SPAN><SPAN> price) { </SPAN>
<LI
class=alt><SPAN> </SPAN><SPAN
class=keyword>return</SPAN><SPAN> findList(bedrooms, bathrooms, price).size();
</SPAN>
<LI class=""><SPAN> } </SPAN>
<LI class=alt><SPAN> </SPAN>
<LI class=""><SPAN> </SPAN><SPAN
class=keyword>private</SPAN><SPAN> List findList(</SPAN><SPAN
class=keyword>int</SPAN><SPAN> bedrooms, </SPAN><SPAN
class=keyword>int</SPAN><SPAN> bathrooms, </SPAN><SPAN
class=keyword>int</SPAN><SPAN> price) { </SPAN>
<LI
class=alt><SPAN> List list = initData();
</SPAN>
<LI
class=""><SPAN> </SPAN><SPAN
class=keyword>for</SPAN><SPAN> (</SPAN><SPAN
class=keyword>int</SPAN><SPAN> i = </SPAN><SPAN
class=number>0</SPAN><SPAN>; i < list.size(); i++) {
</SPAN>
<LI
class=alt><SPAN> Apartment apartment = (Apartment) list.get(i);
</SPAN>
<LI
class=""><SPAN> </SPAN><SPAN
class=keyword>if</SPAN><SPAN> (apartment.getBedrooms() < bedrooms
</SPAN>
<LI
class=alt><SPAN> && apartment.getBathrooms() < bathrooms
</SPAN>
<LI
class=""><SPAN> && apartment.getPrice() >= price) {
</SPAN>
<LI
class=alt><SPAN> list.remove(i);
</SPAN>
<LI
class=""><SPAN> }
</SPAN>
<LI class=alt><SPAN> }
</SPAN>
<LI
class=""><SPAN> </SPAN><SPAN
class=keyword>return</SPAN><SPAN> list; </SPAN>
<LI class=alt><SPAN> } </SPAN>
<LI class=""><SPAN> </SPAN>
<LI class=alt><SPAN> </SPAN>
<LI class=""><SPAN> </SPAN><SPAN
class=keyword>private</SPAN><SPAN> List initData() {
</SPAN>
<LI
class=alt><SPAN> List list = </SPAN><SPAN
class=keyword>new</SPAN><SPAN> ArrayList(); </SPAN>
<LI
class=""><SPAN> Apartment apartment = </SPAN><SPAN
class=keyword>new</SPAN><SPAN> Apartment(); </SPAN>
<LI class=alt><SPAN> </SPAN>
<LI
class=""><SPAN> apartment.setId(</SPAN><SPAN
class=number>16001</SPAN><SPAN>); </SPAN>
<LI
class=alt><SPAN> apartment.setBedrooms(</SPAN><SPAN
class=number>1</SPAN><SPAN>); </SPAN>
<LI
class=""><SPAN> apartment.setBathrooms(</SPAN><SPAN
class=number>1</SPAN><SPAN>); </SPAN>
<LI
class=alt><SPAN> apartment.setPrice(</SPAN><SPAN
class=number>850</SPAN><SPAN>); </SPAN>
<LI
class=""><SPAN> apartment.setAddress(</SPAN><SPAN
class=string>"123 King St. East"</SPAN><SPAN>);
</SPAN>
<LI
class=alt><SPAN> apartment.setCity(</SPAN><SPAN
class=string>"Toronto"</SPAN><SPAN>); </SPAN>
<LI
class=""><SPAN> apartment.setProvince(</SPAN><SPAN
class=string>"ON"</SPAN><SPAN>); </SPAN>
<LI
class=alt><SPAN> list.add(apartment);
</SPAN>
<LI class=""><SPAN> </SPAN>
<LI
class=alt><SPAN> apartment.setId(</SPAN><SPAN
class=number>16002</SPAN><SPAN>); </SPAN>
<LI
class=""><SPAN> apartment.setBedrooms(</SPAN><SPAN
class=number>2</SPAN><SPAN>); </SPAN>
<LI
class=alt><SPAN> apartment.setBathrooms(</SPAN><SPAN
class=number>1</SPAN><SPAN>); </SPAN>
<LI
class=""><SPAN> apartment.setPrice(</SPAN><SPAN
class=number>1000</SPAN><SPAN>); </SPAN>
<LI
class=alt><SPAN> apartment.setAddress(</SPAN><SPAN
class=string>"1023 Yonge Ave"</SPAN><SPAN>); </SPAN>
<LI
class=""><SPAN> apartment.setCity(</SPAN><SPAN
class=string>"Toronto"</SPAN><SPAN>); </SPAN>
<LI
class=alt><SPAN> apartment.setProvince(</SPAN><SPAN
class=string>"ON"</SPAN><SPAN>); </SPAN>
<LI
class=""><SPAN> list.add(apartment);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -