为什么出现这个错误:cannot be resolved to a type

awt_boy 2008-03-16 08:58:13
源文件如下:
<%@ page contentType="text/html; charset=utf-8"%>
<%@ page import="bug.entity.*"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html>
<head>
<script language="JavaScript">
function add() {
document.bugActionForm.id = idC.value;
document.bugActionForm.sta.value = staC.innerText;
document.bugActionForm.url.value = urlC.innerText;
document.bugActionForm.pha = phaC.innerText;
document.bugActionForm.cat = catC.innerText;
document.bugActionForm.ref = refC.innerText;
document.bugActionForm.dis = disC.innerText;
document.bugActionForm.action = "AddBugAction.do";
document.bugActionForm.submit();
}
function search() {
document.bugActionForm.id = idC.value;
document.bugActionForm.sta.value = staC.innerText;
document.bugActionForm.url.value = urlC.innerText;
document.bugActionForm.pha = phaC.innerText;
document.bugActionForm.cat = catC.innerText;
document.bugActionForm.ref = refC.innerText;
document.bugActionForm.dis = disC.innerText;
document.bugActionForm.action = "AddBugAction.do";
document.bugActionForm.submit();
}
function del(id) {
document.bugActionForm.id = id;
document.bugActionForm.action = "DeleteBugAction.do";
document.bugActionForm.submit();
}
</script>
</head>
<body>
<em><bean:message key="message.bugDB"/></em><p>
<table>
<html:errors/>
</table>
<bean:message key="message.id"/>:<input name="id" value="" type="text"> 
<bean:message key="message.sta"/>:<input type="sta" name="textfield"> 
<bean:message key="message.url"/> :<input type="url" name="textfield3">
<p>
<bean:message key="message.pha"/>:<input type="pha" name="textfield2"> 
<bean:message key="message.cat"/>:<input type="cat" name="textfield4">
</p>
<textarea style="height:100" name=refC></textarea>
<textarea style="height:100" name=disC></textarea>
<html:form action="BugAction.do">
<html:hidden property="id"/>
<html:hidden property="sta"/>
<html:hidden property="url"/>
<html:hidden property="pha"/>
<html:hidden property="cat"/>
<html:hidden property="ref"/>
<html:hidden property="dis"/>
<p>
<input type="button" onClick="add();" value="<bean:message key="message.add"/>">
<input type="button" onclick="search();" value="<bean:message key="message.search"/>">
</p>
</html:form>

<table border=1 cellspacing=1 cellpadding=2>
<tr>
<td style="background-color: #808080;font-size: 12pt;color: #ffffff;font-weight: bold;line-height: 15pt;border: 1px solid #808080;"><bean:message key="message.id"/></td>
<td style="background-color: #808080;font-size: 12pt;color: #ffffff;font-weight: bold;line-height: 15pt;border: 1px solid #808080;"><bean:message key="message.sta"/></td>
<td style="background-color: #808080;font-size: 12pt;color: #ffffff;font-weight: bold;line-height: 15pt;border: 1px solid #808080;"><bean:message key="message.url"/></td>
<td style="background-color: #808080;font-size: 12pt;color: #ffffff;font-weight: bold;line-height: 15pt;border: 1px solid #808080;"><bean:message key="message.pha"/></td>
<td style="background-color: #808080;font-size: 12pt;color: #ffffff;font-weight: bold;line-height: 15pt;border: 1px solid #808080;"><bean:message key="message.cat"/></td>
<td style="background-color: #808080;font-size: 12pt;color: #ffffff;font-weight: bold;line-height: 15pt;border: 1px solid #808080;"><bean:message key="message.ref"/></td>
<td style="background-color: #808080;font-size: 12pt;color: #ffffff;font-weight: bold;line-height: 15pt;border: 1px solid #808080;"><bean:message key="message.dis"/></td>
<td style="background-color: #808080;font-size: 12pt;color: #ffffff;font-weight: bold;line-height: 15pt;border: 1px solid #808080;"><bean:message key="message.delete"/></td>
</tr>
<logic:notEmpty name="allBug">
<logic:iterate name="allBug" id="bug" type="bug.entity.Bug">
<tr>
<td style="word-break: break-all;" >
<bean:write property="id" name="bug"/>
</td>
<td style="word-break: break-all;" >
<bean:write property="sta" name="bug"/>
</td>
<td style="word-break: break-all;" >
<bean:write property="url" name="bug"/>
</td>
<td style="word-break: break-all;" >
<bean:write property="pha" name="bug"/>
</td>
<td style="word-break: break-all;" >
<bean:write property="cat" name="bug"/>
</td>
<td style="word-break: break-all;" >
<bean:write property="ref" name="bug"/>
</td>
<td style="word-break: break-all;" >
<bean:write property="dis" name="bug"/>
</td>
<td style="word-break: break-all;" ><input type="button" onclick="del('<%=bug.getId()%>');" value="<bean:message key="message.delete"/>"></td>
</tr>
</logic:iterate>
</logic:notEmpty>
</table>
</body>
</html>
...全文
18031 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
热爱生活 2012-04-12
  • 打赏
  • 举报
回复
问题解决了没有?
snowskylanniao 2010-12-09
  • 打赏
  • 举报
回复
你需要写一个类型转换,你传递是字符串要转换成类对象。public class BugConverter extends StrutsTypeConverter方法省略} 再一个properities文件就是配置路劲
awt_boy 2008-03-17
  • 打赏
  • 举报
回复
struts1.1中logic:iterate的属性type指的是定义了集合中保存的类型,而我的bug.entity.Bug就是Bug.java,这是一个javabean
完全符合呀,而且.properties文件我也是编号unicode码了的啊,怎么会错呢?
application.properties文件内容如下:
#错误信息
error.eventcodeRequest=<tr><td><strong>必须有编号</strong></td></tr>
error.sqlAddError=<tr><td><strong>添加失败</strong></td></tr>
error.sqlDelError=<tr><td><strong>删除失败</strong></td></tr>

#显示信息
message.bugDB=信息插入
message.id=编号
message.sta=状态
message.url=地址
message.pha=阶段
message.cat=类别
message.ref=参考
message.dis=备注
message.search=查询
message.add=增加
message.delete=删除
message.bug=信息插入


awt_boy 2008-03-17
  • 打赏
  • 举报
回复
struts1.1中logic:iterate的属性type指的是定义了集合中保存的类型,而我的bug.entity.Bug就是Bug.java,这是一个javabean
完全符合呀,而且.properties文件我也是编号unicode码了的啊,怎么会错呢?
application.properties文件内容如下:
#错误信息
error.eventcodeRequest=<tr><td><strong>必须有编号</strong></td></tr>
error.sqlAddError=<tr><td><strong>添加失败</strong></td></tr>
error.sqlDelError=<tr><td><strong>删除失败</strong></td></tr>

#显示信息
message.bugDB=信息插入
message.id=编号
message.sta=状态
message.url=地址
message.pha=阶段
message.cat=类别
message.ref=参考
message.dis=备注
message.search=查询
message.add=增加
message.delete=删除
message.bug=信息插入


dracularking 2008-03-16
  • 打赏
  • 举报
回复
你可以单独使用这个Type来测试下
type="bug.entity.Bug"

awt_boy 2008-03-16
  • 打赏
  • 举报
回复
不知道struts的application.properties怎么写
我想可能是这里面错了,但不会unicode码
老紫竹 2008-03-16
  • 打赏
  • 举报
回复
把你的java编译好的class 复制到
WEB-INF/classes
下面
,如果是eclipse ,请参考这个
http://www.java2000.net/viewthread.jsp?tid=700
yibunengjing 2008-03-16
  • 打赏
  • 举报
回复
从错误信息来看就是bug.entity.Bug这个类没有引入的关系,再去仔细检查一下代码
在jsp中去掉这个类的引用再调试下,如调试通过,再从这个类上面着手查问题
awt_boy 2008-03-16
  • 打赏
  • 举报
回复
有啊,bug.entity.Bug这个包是我编写的啊,怎么不能解析的?
hugh_z 2008-03-16
  • 打赏
  • 举报
回复
同意楼上。
zhang825015 2008-03-16
  • 打赏
  • 举报
回复
没有这个bug.entity.Bug类
awt_boy 2008-03-16
  • 打赏
  • 举报
回复
出错情况如下:

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

An error occurred at line: 78 in the jsp file: /biye/showBug.jsp
bug.entity.Bug cannot be resolved to a type
75: <td style="background-color: #808080;font-size: 12pt;color: #ffffff;font-weight: bold;line-height: 15pt;border: 1px solid #808080;"><bean:message key="message.delete"/></td>
76: </tr>
77: <logic:notEmpty name="allBug">
78: <logic:iterate name="allBug" id="bug" type="bug.entity.Bug">
79: <tr>
80: <td style="word-break: break-all;" >
81: <bean:write property="id" name="bug"/>


An error occurred at line: 78 in the jsp file: /biye/showBug.jsp
bug.entity.Bug cannot be resolved to a type
75: <td style="background-color: #808080;font-size: 12pt;color: #ffffff;font-weight: bold;line-height: 15pt;border: 1px solid #808080;"><bean:message key="message.delete"/></td>
76: </tr>
77: <logic:notEmpty name="allBug">
78: <logic:iterate name="allBug" id="bug" type="bug.entity.Bug">
79: <tr>
80: <td style="word-break: break-all;" >
81: <bean:write property="id" name="bug"/>


An error occurred at line: 280 in the generated java file
bug.entity.Bug cannot be resolved to a type

Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

fenghongx 2008-03-16
  • 打赏
  • 举报
回复
确定你的类路径和类放置的位置都正确~~另外LZ你可以试试在<%@PAGE IMPORT%>引入详细的类~~
fenghongx 2008-03-16
  • 打赏
  • 举报
回复
如果bug.entity.Bug这个类是LZ你自己写的话那就是没有被正确导入~~程序找不到~~

81,090

社区成员

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

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