jspѧϰÈռǣ¨Ò»£©javabeanµÄʹÓúÍJavaBean+servletµÄmvc
jspµÄÔËÐлúÖƱÈ.netµÄwebformµÄ¼Ü¹¹·½±ã¶àÁË£¬Ö»ÒªÅäÖÃÁËjava sdkºÍtomcat£¬ÔÚjspÄÚǶ´úÂë¾ÍÄÜÔËÐС£Õâ¸ö¸úÒÔÇ°µÄaspÓеãÀàËÆ¡£
ºóÀ´£¬ÎªÁËÖØÓÃÂß¼´úÂ벿·Ö£¬Íâ¼ÓÄÚǶҳÃæjava´úÂëÌ«¶à£¬²»ºÃ¹ÜÀí£¬ÓÚÊdzöÏÖÁËjsp+javabeanµÄÁ½²ã¼Ü¹¹¡£¾ÍÊÇ°ÑÂß¼´úÂ벿·ÖÌáÈ¡³ö À´£¬·ÅÔÚclassÀïÃ棬ȻºóÔÚjspÒ³Ãæµ÷ÓÃclass£»calss¹¦ÄÜÓеãÀàËÆÓÚwebformµÄºǫ́´¦Àí´úÂ룬µ«ÊDZ¾ÖÊÉÏÊÇÍêÈ«²»Í¬ µÄ£»webformµÄºǫ́´úÂëÊÇ¿ÉÒÔÖ±½Ó¿ØÖÆaspxÒ³ÃæµÄ·þÎñÆ÷¿Ø¼þ£¬¶øJavaBeanÊÇ´«ÊäÊý¾Ý£¬»ò¼æ²¢´¦ÀíÊý¾Ý£¬È»ºóÔÚjspÏÔ Ê¾£¬jsp+JavaBeanģʽµÄÁ½²ã·Ö¹¤ºÜÃ÷È·¡£
¶¨ÒåJavaBean£º
package javaweb; public class javabean { private String username; private String password; public void setUsername(String username) { this.username=username; } public void setPassword(String password) { this.password=password; } public String getUsername() { return username; } public String getPassword() { return password; } } ¹¹½¨login.jspºÍwelcom.jsp:
login.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<center>
<form method=post action="wellcom.jsp">
username<input type=text name=username>
<br><br>
password<input type=password name=password>
<br><br>
<input type=submit value="×¢²á">
</form>
</center>
</html>
welcom.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<jsp:useBean id="hello" class="javaweb.javabean" scope="session" />
<jsp:setProperty name="hello" property="*" />
<%
//hello.username = "myname";
%>
your username is:<%= hello.getUsername() %>
<br><br>
your password is:<jsp:getProperty name="hello" property="password"/>
<br><br>
</html>
jsp + javaBean + servlet (Ë׳ƵÄmvc½á¹¹)
֮ǰµÄJavaBean¾ÍÊÇ·ÖÁ½²ã£¬ÏÖÔÚ¼Ó¸öservlet¾Í·ÖÈý²ã¡£servletÓеãÏñasp.net mvc¿ò¼ÜµÄ·Óɹ¦ÄÜ£¬Ò²¾ÍÊÇÒ³Ãæ¿ØÖÆ̨£¬¸ºÔð¿ØÖÆÒ³Ãæ´«ÖµºÍ´«Êä¡£ÉÏÃæµÄ´úÂë²»±ä£¬¼Ó¶àÒ»¸öservlet:
import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import com.huanlin.UserInfoBean; public class HelloServlet2 extends HttpServlet { public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html; charset=GBK"); request.setCharacterEncoding("GBK"); //´´½¨JavaBeanµÄ¶ÔÏó javabean bean = new javabean(); bean.setUserName( request.getParameter("username").toStrng()); HttpSession session = request.getSession(); session.setAttribute("userInfo", userInfo); // Ç°ÍùÖ¸¶¨µÄÍøÒ³ response.sendRedirect("welcom.jsp") } }µ±È»»¹ÒªÉèÖÃWEB-INFÏÂÃæµÄweb.xmlÉèÖ÷ÓÉÁË£º
<servlet> <servlet-name> login </servlet-name> <servlet-class> javaweb.javabean </servlet-class> </servlet> <servlet-mapping> <servlet-name>login</servlet-name> <url-pattern>/login.do</url-pattern> </servlet-mapping>
È»ºóÐÞ¸Älogin.jsp ±êÇ©formµÄaction=¡±/login.do¡±
ÕâÑùÒ»¸ö¼òµ¥µÄmvc¾ÍʵÏÖÁË
ÍƼöÐÅÏ¢
- ÔÝÎ޼Ǽ
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- java urlÖØд¼¼Êõ(UrlReWriter)
- [ת]JavaµÄÊý×飨Array£©¡¢Vector¡¢ArrayLis....
- jsp»·¾³ÏÂajaxÂÒÂëÎÊÌâµÄ½â¾ö
- JSP¼¼Êõ Ö¸Áî ÂÒÂëÎÊÌâ ÔËÐÐÔÀíºÍ¾Å´óÒþʽ¶ÔÏó web¿ª·¢µÄË....
- JAVA ˮӡ ͼƬ ÎÄ×Ö
- java¶þ½øÖÆ£¬ÔÂë¡¢·´Âë¡¢²¹Â롢λÔËËã
- Java WebÓ¦ÓÃÆô¶¯¼ä¸ôÖ´ÐеijÌÐò
- jspÉú³ÉxmlÎļþʾÀý
- javaÖÐÀà±äÁ¿¡¢Àà·½·¨¡¢ÊµÀý±äÁ¿¡¢ÊµÀý·½·¨
- JSPÒ³ÃæµÄÎåÖÖÌøת·½·¨
ÆÀÂÛ