日期:2014-05-18  浏览次数:20687 次

新人初学,卡在起点~Jsp的小问题
我是刚刚入手的JSP,按照教材编写简单的Bean测试,主要通过对“用户名”、“密码”和“年龄”的设置和查询练习对Bean的操作,却遇到了很大的问题,希望大家不吝赐教。
使用JDK   6+Tomcat   5.0.28+NetBeans   5.5进行开发。
源代码如下:

/**
TestBean.java
*/

package   com.jspdev.ch3;

public   class   TestBean
{
public   String   userName;
public   String   password;
public   int   age;  

public   void   setUserName(String   name)
{
this.userName=name;
}
public   void   setPassword(String   passwordTemp)

{
this.password=passwordTemp;
}
public   String     getUserName()
{
return   this.userName;
}
public   String   getPassword()
{
return   password;
}
public   int   getAge()
{
return   this.age;
}
public   void   setAge(int   ageTemp)
{
this.age=ageTemp;
}
}

/**
TestBean.java   结束
*/


/**
register.jsp
*/

<%@   page   contentType= "text/html;charset=gb2312 "%>  
<jsp:useBean   id= "user "   scope= "page "   class= "com.jspdev.ch3.TestBean "/>
<jsp:setProperty   name= "user "   property= "* "/>
<html>  
<body>  
注册成功: <br>
<hr>
使用bean属性方法: <br>
用户名: <%=user.getUserName()   %> <br>
密码: <%=user.getPassword()   %> <br>
年龄: <%=user.getAge()   %> <br>
<hr>
使用getProperty: <br>
用户名: <jsp:getProperty   name= "user "   property= "userName "/> <br>
密码: <jsp:getProperty   name= "user "   property= "password "/> <br>
年龄: <jsp:getProperty   name= "user "   property= "age "/> <br>
</body>  
</html>  

/**
register.jsp   结束
*/


/**
regiester.html
*/

<html>
<body>
用户信息注册: <br> <hr>
<form   method= "get "   action= "register.jsp ">
<table>
<tr> <td> 姓名: <input   name= "userName "   type= "text "> </td> </tr>
<tr> <td> 密码: <input   name= "password "   type= "password "> </td> </tr>
<tr> <td> 年龄: <input   name= "age "   type= "text "> </td> </tr>
<tr> <td> <input   type=submit   value= "submit "> </td> </tr>
</table>
</form>
</body>
</html>

/**
regiester.html   结束
*/

但是无论直接通过IE运行还是NetBeans编译,register.jsp始终通过不过编译。
在NetBeans中报错:
compile-single-jsp:
Duplicated   project   name   in   import.   Project   Register-impl   defined   first   in   C:\Documents   and   Settings\Java\Register\nbproject\ant-deploy.xml   and   again   in   C:\Documents   and   Settings\Java\Register\nbproject\build-impl.xml
init:
deps-module-jar:
deps-ear-jar:
deps-jar: