Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

struts2,jspÒ³ÃæÏòactionÌá½»list¶ÔÏó

Struts2
ÖÐÖ§³ÖʹÓÃListÔÚÒ³ÃæºÍActionÖ®¼äÖ±½Ó´«µÝ±í¸ñÊý¾Ý¡£ÏÂÃæÊÇÒ»¸öʾÀý£º
public class Person {
int id;
String name;
int age;
float
height;
}
ÕâÊÇÒ»¸öPOJO£¬getterºÍsettingÊ¡ÂÔÁË¡£
actionÖпÉÒÔÕâÑùʹÓãº
public class MyAction {
public List getPeopleList() { … }
public
void setPeopleList( List peopleList ) { … }

}
ÔÚÎÒÃÇʹÓÃPersonÀà֮ǰ£¬ÐèÒªÌí¼ÓÒ»¸öÅäÖÃÎļþ£¬MyAction-conversion.properties£¬°ÑÕâ¸öÎļþºÍMyAction·ÅÔÚÒ»Æð¡£
Õâ¸öÎļþÀïÖ»ÓÐÒ»ÐÐÄÚÈÝ£º
Element_peopleList=Person
ǰ׺Element_ÊÇÒ»¸ö³£Á¿£¬±íÃ÷µÈºÅ×ó±ßµÄ±í´ïʽÖиúÔÚÕâ¸ö³£Á¿ºóÃæµÄÊÇActionÀàÖÐÒ»¸öListÀàÐ͵Ä×Ö¶ÎÃû¡£
µÈºÅÓұߵıí´ïʽÊÇÈ«ÀàÃû£¨°üº¬package£©
ÏÂÃæÊÇÒ»¸öÒ³ÃæµÄ´úÂëÆ¬¶Î£º
<s:form action="update"
method="post" >
       <s:iterator value="peopleList" status="stat">
       <s:hidden name="peopleList[%{#stat.index}].id"
value="%{peopleList[#stat.index].id}"/>
       <s:textfield label="Name"
name="peopleList[%{#stat.index}].name"
value="%{peopleList[#stat.index].name}"/>
       <s:textfield label="Age"
name="peopleList[%{#stat.index}].age"
value="%{peopleList[#stat.index].age}" />
       <s:textfield
label="Height" name="peopleList[%{#stat.index}].height"
value="%{peopleList[#stat.index].height}"/>
       <br/>
       </s:iterator>
        <s:submit value="Update"/>
</s:form>
ʹÓÃÕâ¶Î´úÂ룬Struts2
»á´´½¨Ò»¸öPersonÀàµÄArrayList£¬²¢ÇÒÓÃsetPersonListÕâ¸ö·½·¨°ÑÒ³Ãæ±í¸ñÖеÄÖµ´«µÝ»ØAction¡£
Èç¹ûÄãÊÇÏë´ÓÓû§½çÃæÖж¯Ì¬´´½¨ÁбíÖµ£¬ÐèÒªÔÊÐíStruts2
¸øÁбíÖÐÀ


Ïà¹ØÎĵµ£º

ÎÒ¿ª·¢Ò»¸öjspϵͳʱÅöµ½µÄÎÊÌâ

1.No getter method for property name problem(struts)
ÓÐÒ»ÖÖ¿ÉÄÜÊÇBeanûÓÐдÏàÓ¦µÄget·½·¨£¬ÀýÈç±äÁ¿userNameµÄget·½·¨ÊÇgetUserName£»
»¹ÓоÍÊÇÕâ¸öBeanΪ¿Õ£»
2.
MyEclipseµÄ×Ô¶¯Ìí¼ÓstrutsºÍhibernate¹¦Äܲ»ÄÜ·µ»Ø£¬Çë×¢Ò⣡
ËùÒÔÎÒÏÈʹÓÃMyEclipseµ¼ÈëstrutsºÍhibernate£¬È»ºó½«ËüÃǵÄjarµ¼Èëµ½ÁíÍâÒ»¸öн¨µÄ ......

JSPÖÐÓë·¾¶Ïà¹ØµÄ³£Óõö·½·¨


http:/localhost/123/jsp/test.jsp:
<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logi ......

JSPÓëSevletµÄÏ໥ͨÐÅ·½Ê½(¶þ)

Servlet£º
ÔÚServletÖУ¬Ìø×ªÔÚdoGet»òÕßdoPost·½·¨ÖÐʵÏÖ¡£
<1>redirectʵÏÖÒ³ÃæÌø×ª£º
 response.sendRedirect("/login.jsp");
 ·½·¨µÄ²ÎÊýÊÇÏà¶Ô·¾¶£¬É趨Õâ¸ö²ÎÊý¿ÉÒÔÊ¹Ò³ÃæÌø×ªµ½ÈκÎÒ³Ãæ£¬°üÀ¨www.baidu.comµÈÍøÂçÒ³Ãæ¡£
 Ìø×ªºóÄã¿ÉÒÔ·¢ÏÖµØÖ·À¸·¢ÉúÁ˱仯¡£
 µ×²ãÔ­Àí£ºÊ¹ÓÃredir ......

jsp Ö®Filter

(1) ÇëÇóÐÅÏ¢±àÂëת»¯µÄFilter
importjava.io.IOException;
importjava.util.Enumeration;
importjavax.servlet.Filter;
importjavax.servlet.FilterChain;
importjavax.servlet.FilterConfig;
importjavax.servlet.ServletException;
importjavax.servlet.ServletRequest;
importjavax.servlet.ServletResponse;
......

JSPʵÀýÒ»¡¢¹ºÎï³µ


֪ʶ׼±¸£º
JDBC·ÃÎÊÊý¾Ý¿âµÄ»ù±¾²½Öè
£¨1£©¡¢½«Êý¾Ý¿âµÄJDBCÇý¶¯¼ÓÔØµ½¹¤³ÌÀà¿âÖС£
£¨2£©¡¢¼ÓÔØJDBCÇý¶¯£¬²¢½«Æä×¢²áµ½DriverManagerÖС£ÏÂÃæÊÇһЩÖ÷Á÷Êý¾Ý¿âµÄJDBCÇý¶¯¼ÓÔØ×¢²áÂ룺
¢Ù¡¢oracleÊý¾Ý¿â
Class.forName(“oracle.jdbc.driver.OracleDriver”).newInstance();
¢Ú¡¢Sql Server 7.0/2000Êý¾ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ