JSP使用的例子.谁能给个?
在Servlet里面设置一个类的名字,
如:dog.setName( "aaabbbccc ");
然后到JSP里面打印出来.
可我打印的老是null.得不到 "aaabbbccc ".
就是这样的一个例子. 只要能在Servlet里面设置在JSP中打印出来就行了
JSP就像下面这样.只许用 "动作 ".
<jsp:useBean id= "pdog " class= "foo.Dog " scope= "request "/>
<jsp:getProperty name= "dog " property= "name "/>
------解决方案--------------------楼上对不?
------解决方案--------------------给分
------解决方案--------------------sevlet中
Dog dog=new Dog()
dog.setName( "aaabbbccc ");
Session session=request.getSession();//这里忘记了是不是这样定义Session,我这没有ide
session.setAttribute( "user ",users);
jsp中
<jsp:useBean id= "dog " class= "foo.Dog " scope= "session "/>
<jsp:getProperty name= "dog " property= "name "/>
------解决方案--------------------路过看看
------解决方案--------------------sevlet中
Dog dog=new Dog()
dog.setName( "aaabbbccc ");
request.setAttribute( "dog ",dog);
request.getDispat....( "/页面路径 ").forword(...);
页面里
<%
(Dog)dog = request.getAttribute( "dog ");
if(dog!=null)
{
out.println(dog.getName());
}
%>