jsp页面中使用javabean

<%@ page language="java" import="java.util.*,com.loaderman.demo.b_cases.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
    <title>jsp页面中使用javabean</title>  
  </head>
  
  <body>
    <%
        //Student stu = new Student();
        //stu.setName("rose");
        //stu.setAge(20);
        
        //stu.getName();
     %>
     <%---创建对象 --%>
     <jsp:useBean id="stu" class="com.loaderman.demo.Student"></jsp:useBean>

     <%--赋值 --%>
     <jsp:setProperty property="name" name="stu" value="jacky"/>

       <%--获取--%>
      <jsp:getProperty property="name" name="stu"/>
  </body>
</html>

 

posted on 2018-11-22 17:22  LoaderMan  阅读(493)  评论(0编辑  收藏  举报

导航