刚学。帮找下下面一段代码错误

jinzhai 2008-11-05 04:54:36
<%!
class cellPhone {
string phoneType;
string phoneModel;
int phonePrice;
string getType() {
return this.phoneType;
}
string getModel() {
return this.phoneModel;
}
int getPrice() {
return this.phonePrice;
}
}
%>
<%
phineDate myphone = new phoneDate();
myPhone.phoneType = "Siemens";
myPhone.phoneModel = "s2588";
myPhone.phonePrice = 500;
myPhone.owner = "MAC";
%>
移动电话:<br>
品牌:<%= myPhone.phoneType%>
型号:<%= myPhone.phoneModel%>
价格:<%= myPhone.phonePrice%>
姓名:<%= myPhone.myPhone.owner%>
...全文
110 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
hcqhappy 2008-11-07
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 kitty009 的回复:]
楼上正解
错误信息中
org.apache.jasper.JasperException: Unable to compile class for JSP:
——JasperException 代表jsp语法错误
An error occurred at line: 4 in the jsp file: /jsptest/3.08.jsp
——这个说明了第四行诗错误的
string cannot be resolved to a type
——这个说string不是个正确的类型

拜托,异常都说那么明白了,怎么还研究是不是get方法的问题?只有get没有set只能说明不是bean文件或者…
[/Quote]
一本书 如果他的示例代码都这样 能是什么好书
dynastytan 2008-11-05
  • 打赏
  • 举报
回复
路过
shenjie1989 2008-11-05
  • 打赏
  • 举报
回复
加一个set方法。
kitty009 2008-11-05
  • 打赏
  • 举报
回复
楼上正解
错误信息中
org.apache.jasper.JasperException: Unable to compile class for JSP:
——JasperException 代表jsp语法错误
An error occurred at line: 4 in the jsp file: /jsptest/3.08.jsp
——这个说明了第四行诗错误的
string cannot be resolved to a type
——这个说string不是个正确的类型

拜托,异常都说那么明白了,怎么还研究是不是get方法的问题?只有get没有set只能说明不是bean文件或者代码不规范而已,就算不写set照样不报错的。
不否认有些书的确有错误,但是不能出现问题就怀疑书不对吧~~
hjjjizhan 2008-11-05
  • 打赏
  • 举报
回复
没有Set方法 还有就是String是这个
hp5212000 2008-11-05
  • 打赏
  • 举报
回复
是String 不是 string, 错误信息已经提示的很明显了 "string cannot be resolved to a type "
hcqhappy 2008-11-05
  • 打赏
  • 举报
回复

<%!
class CellPhone {
private String phoneType;

private String phoneModel;

private int phonePrice;

public String getPhoneModel() {
return phoneModel;
}

public void setPhoneModel(String phoneModel) {
this.phoneModel = phoneModel;
}

public int getPhonePrice() {
return phonePrice;
}

public void setPhonePrice(int phonePrice) {
this.phonePrice = phonePrice;
}

public String getPhoneType() {
return phoneType;
}

public void setPhoneType(String phoneType) {
this.phoneType = phoneType;
}
%>
<%
CellPhone myphone = new CellPhone();
myphone.setPhoneModel("Siemens");
myphone.setPhonePrice(500);
myphone.setPhoneType("s2588");
%>
移动电话: <br>
品牌: <%= myphone.getPhoneModel()%>
型号: <%= myphone.getPhonePrice()%>
价格: <%= myphone.getPhoneType()%>


hcqhappy 2008-11-05
  • 打赏
  • 举报
回复


package com.ccit.ra.test;

public class CellPhone {
private String phoneType;

private String phoneModel;

private int phonePrice;

public String getPhoneModel() {
return phoneModel;
}

public void setPhoneModel(String phoneModel) {
this.phoneModel = phoneModel;
}

public int getPhonePrice() {
return phonePrice;
}

public void setPhonePrice(int phonePrice) {
this.phonePrice = phonePrice;
}

public String getPhoneType() {
return phoneType;
}

public void setPhoneType(String phoneType) {
this.phoneType = phoneType;
}

public static void main(String[] args) {
CellPhone myphone = new CellPhone();
myphone.setPhoneModel("Siemens");
myphone.setPhonePrice(500);
myphone.setPhoneType("s2588");

System.out.println(myphone.getPhoneModel());
System.out.println(myphone.getPhonePrice());
System.out.println(myphone.getPhoneType());

}
}

HuangIs 2008-11-05
  • 打赏
  • 举报
回复
那书绝对有问题 同意楼上的意见
hcqhappy 2008-11-05
  • 打赏
  • 举报
回复
什么书啊 误人子弟 搜索下 javabean吧
jinzhai 2008-11-05
  • 打赏
  • 举报
回复
我这是按着书上的范例写的
我没有发现
一个字母都不错,大小写也区分了,符号也不错
测试 :
提示错误为:
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 4 in the jsp file: /jsptest/3.08.jsp
string cannot be resolved to a type

SmallFishZhang 2008-11-05
  • 打赏
  • 举报
回复
光有get方法,没有set方法吗

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧