代码呢,你这样我们如何知道啊
一般比较的话,常量最好在前面
如
if("".equals())....
一般比较的话,常量最好在前面
如
if("".equals())....
解决方案 »
- 什么是java
- MyEclipse 6.5问题,当我每次启动运行的时候都会提示说
- 求高手解答webservice客户端到服务出现的乱码问题
- 高手请进java.io.IOException: tmpFile.renameTo(classFile) failed
- webwork这xwork.xml问题
- RESIN 显示中文出现乱码
- java中如何实现对所有图片 都能在同一面板中全部显示??
- 高手一定要看:ejb与ejb互相调用的问题
- STRUTS中分页,大家是如何处理的?UP有分
- System.out.print()和out.print()在使用时有什么区别?
- 数据转码后首字符出现一个框框,其它都能正常显示,是UNICODE到string的转换,发送前都已经trim()过了,先谢各位大哥了?
- 在使用htmlparser时遇到的问题。请高手帮看下。
<%@ page language="java" contentType="text/html; charset=GBK"%>
<jsp:directive.page import="com.zel.dao.DAOFactory" />
<jsp:directive.page import="com.zel.domain.Specialty" />
<jsp:directive.page import="com.zel.dao.SpecialtyDAO" />
<jsp:directive.page import="java.util.*" />
<jsp:directive.page import="java.lang.Exception" />
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
<html:base /> <title>添加学生界面</title>
<style type="text/css">
<!--
.style1 {
color: #0000FF;
font-weight: bold;
font-size: xx-large;
}
.style2 {color: #FF0000}
-->
</style> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--></head><body> <%--
String admin_id = (String) session.getAttribute("id");
if (admin_id == null) {
response.sendRedirect("login.jsp");
} --%>
<% int total=-1;
Iterator it =null;
Specialty spe;
String spename;
try{
SpecialtyDAO speDao = DAOFactory.getInstance().createSpecialtyDAO();
if(speDao!=null){
List list = speDao.getSpecialty();
total = list.size();
it = list.iterator();
}else{System.out.println("这里的JAVA代码不能运行!!!");}}catch(Exception e){
out.print("<br>");
out.print("抛出的异常信息为:"+e.toString());
}
finally{
//total=1;
spename="2004数学与应用数学";
}
%>
<h1 class="style1" align="center">
添加学生
</h1>
<html:form method="post" action="/student">
<center>
<span class="style2"> <html:errors /> </span>
</center>
<table width="49%" height="50" border="0" align="center"
cellpadding="2" cellspacing="2">
<tr>
<td align="right" width="30%">
学生学号:
</td>
<td width="60%" border="4">
<html:text property="stunumber" value="" />
<html:errors property="stunumber.null" />
</td>
</tr>
<tr>
<td align="right" width="30%">
学生姓名:
</td>
<td width="60%" border="4">
<html:text property="name" value="" />
<html:errors property="studentname.null" />
</td>
</tr>
<tr>
<td align="right" width="30%">
学生密码:
</td>
<td width="60%" border="4">
<html:text property="password" value="" />
<html:errors property="password.null" />
</td>
</tr>
<%
if (it != null) {
%>
<tr>
<td align="right">
学生专业:
</td>
<td border="4">
<html:select property="spe_name" multiple="true" size="3" value="0">
<%
for (int i = 0; i < total; i++) {
spe = (Specialty) it.next();
spename = spe.getSpename();
%>
<html:option key="a<%=i%>" value="<%=spename%>"><%=spename%></html:option>
<%
}
%>
</html:select>
<html:errors property="spe_name.null" />
</td>
</tr>
<%
} else {
%>
<center>
<h4 class="style2" align="center">
<%="遗憾,专业不能从数据库中得出!"%>
</h4>
</center>
<tr>
<td align="right">
学生专业:
</td>
<td border="4">
<html:text property="spe_name" value="<%=spename%>" />
</td>
</tr> <%
}
%>
<tr>
<td></td>
<td>
<html:submit value="提交" />
</td>
</tr>
</table>
</html:form>
<p align="center">
</p>
<a href="admin.jsp"><<返回 </a>
</body>
</html:html>
SpecialtyDAO speDao = DAOFactory.getInstance().createSpecialtyDAO();
if(speDao!=null){
List list = speDao.getSpecialty();
total = list.size(); //判断下 list 是不是null就ok了,为空的话检查 SpecialtyDAO的getSpecialty()方法吧
it = list.iterator();
}else{System.out.println("这里的JAVA代码不能运行!!!");}}catch(Exception e){
out.print(" <br>");
out.print("抛出的异常信息为:"+e.toString());
}