package bean;
import java.sql.*;
import javax.sql.*;
import java.util.*;
import form.*;
import tools.*;
import java.io.*;
public class KjwxBean{
private Connection con = null;
private db dbcon=new db();
public KjwxBean() {
this.con = dbcon.getConnection();
}
public void addKjwx(Kjwx kjwx)throws Exception
{
this.executeHelper("insert into kejiwenxian values('"+kjwx.getMc()+"','"+kjwx.getSl()+"',"+kjwx.getScdw()+",'"+kjwx.getYuyan()+")");
}
public Collection getKjwxs() throws Exception
{
return this.getKjwxHelper("select * from kejiwenxian");
}
public void deleteKjwx(String mc)throws Exception
{
try
{
this.executeHelper("Delete from kejiwenxian where mingchen='"+mc+"'");
}
catch(Exception e)
{
e.printStackTrace();
throw e;
}
}
public void modKjwx(Kjwx kjwx,String mingchen)throws Exception
{
this.executeHelper("update kejiwenxian set mingchen='"+kjwx.getMc()+"' shuliang='"+kjwx.getSl()+"' shoucangdanwei="+kjwx.getScdw()+" yuyan='"+kjwx.getYuyan()+"' where mingchen='"+mingchen+"'");
}
private Collection getKjwxHelper(String sql)throws Exception
{
Statement stmt=con.createStatement();
ResultSet rst=stmt.executeQuery(sql);
Collection ret=new ArrayList();
while(rst.next())
{
Kjwx temp=new Kjwx();
temp.setMc(rst.getString("mingchen"));
temp.setSl(rst.getString("shuliang"));
temp.setScdw(rst.getString("shoucangdanwei"));
temp.setYuyan(rst.getString("yuyan")); ret.add(temp);
}
return ret;
}
private void executeHelper(String sql)throws Exception
{
Statement stmt=con.createStatement();
stmt.executeUpdate(sql);
}}
<%@page contentType="text/html;charset=gb2312"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<jsp:useBean id="kjwxBean" class="bean.KjwxBean" scope="session"/>
<c:set var="kjwxs" value="${kjwxBean.kjwxs}"/>
<html:html locale="true">
<head>
<link href="<html:rewrite page="/rr.css" />" rel="stylesheet" type="text/css">
<title>查看所有的科技文献</title>
</head>
<body>
<center><h1>查看所有的科技文献</h1><logic:messagesPresent>
<span id="errorsHeader"><bean:message key="errors.validation.header"/></span>
<html:messages id="error">
<li><c:out value="${error}"/></li>
</html:messages>
<hr>
</logic:messagesPresent>
<html:errors/>
<table width="100%"height="48" border="1"cellpadding="0"cellspacing="0"bordercolor="#FFFFFF"bordercolordark="#CCCCCC"bordercolorlight="#FFFFFF">
<tr bgcolor="#eeeeee">
<td width="22%" height="24"align="center"><b>名称</b></td>
<td width="11%"align="center"><b>数量</b></td>
<td width="40%"align="center"><b>收藏单位</b></td>
<td width="11%"align="center"><b>语言(0中:1外)</b></td>
<td width="8%"align="center"><b>修改</b></td>
<td width="8%"align="center"><b>删除</b></td> </tr>
<logic:iterate id="emps" name="kjwxs" >
<tr bgcolor="#FFFF88">
<td>
<bean:write name="emps" property="mingchen" /></td>
<td>
<bean:write name="emps" property="shuliang" /></td>
<td>
<bean:write name="emps" property="shoucangdanwei" /></td>
<td>
<bean:write name="emps" property="yuyan" /></td>
<td>
</tr>
</logic:iterate>
</table>
</center>
</body>
</html:html>
错误javax.servlet.ServletException: An error occurred while evaluating custom action attribute "value" with value "${kjwxBean.kjwxs}": An error occurred while getting property "kjwxs" from an instance of class bean.KjwxBean (java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid column name: mc)
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.manage.m_jsp._jspService(m_jsp.java:268)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
root cause javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "value" with value "${kjwxBean.kjwxs}": An error occurred while getting property "kjwxs" from an instance of class bean.KjwxBean (java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid column name: mc)
org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:146)
org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:166)
org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate(ExpressionEvaluatorManager.java:112)
org.apache.taglibs.standard.tag.el.core.ExpressionUtil.evalNotNull(ExpressionUtil.java:85)
org.apache.taglibs.standard.tag.el.core.SetTag.evaluateExpressions(SetTag.java:147)
org.apache.taglibs.standard.tag.el.core.SetTag.doStartTag(SetTag.java:95)
org.apache.jsp.manage.m_jsp._jspx_meth_c_set_0(m_jsp.java:285)
org.apache.jsp.manage.m_jsp._jspService(m_jsp.java:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
import java.sql.*;
import javax.sql.*;
import java.util.*;
import form.*;
import tools.*;
import java.io.*;
public class KjwxBean{
private Connection con = null;
private db dbcon=new db();
public KjwxBean() {
this.con = dbcon.getConnection();
}
public void addKjwx(Kjwx kjwx)throws Exception
{
this.executeHelper("insert into kejiwenxian values('"+kjwx.getMc()+"','"+kjwx.getSl()+"',"+kjwx.getScdw()+",'"+kjwx.getYuyan()+")");
}
public Collection getKjwxs() throws Exception
{
return this.getKjwxHelper("select * from kejiwenxian");
}
public void deleteKjwx(String mc)throws Exception
{
try
{
this.executeHelper("Delete from kejiwenxian where mingchen='"+mc+"'");
}
catch(Exception e)
{
e.printStackTrace();
throw e;
}
}
public void modKjwx(Kjwx kjwx,String mingchen)throws Exception
{
this.executeHelper("update kejiwenxian set mingchen='"+kjwx.getMc()+"' shuliang='"+kjwx.getSl()+"' shoucangdanwei="+kjwx.getScdw()+" yuyan='"+kjwx.getYuyan()+"' where mingchen='"+mingchen+"'");
}
private Collection getKjwxHelper(String sql)throws Exception
{
Statement stmt=con.createStatement();
ResultSet rst=stmt.executeQuery(sql);
Collection ret=new ArrayList();
while(rst.next())
{
Kjwx temp=new Kjwx();
temp.setMc(rst.getString("mingchen"));
temp.setSl(rst.getString("shuliang"));
temp.setScdw(rst.getString("shoucangdanwei"));
temp.setYuyan(rst.getString("yuyan")); ret.add(temp);
}
return ret;
}
private void executeHelper(String sql)throws Exception
{
Statement stmt=con.createStatement();
stmt.executeUpdate(sql);
}}
<%@page contentType="text/html;charset=gb2312"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<jsp:useBean id="kjwxBean" class="bean.KjwxBean" scope="session"/>
<c:set var="kjwxs" value="${kjwxBean.kjwxs}"/>
<html:html locale="true">
<head>
<link href="<html:rewrite page="/rr.css" />" rel="stylesheet" type="text/css">
<title>查看所有的科技文献</title>
</head>
<body>
<center><h1>查看所有的科技文献</h1><logic:messagesPresent>
<span id="errorsHeader"><bean:message key="errors.validation.header"/></span>
<html:messages id="error">
<li><c:out value="${error}"/></li>
</html:messages>
<hr>
</logic:messagesPresent>
<html:errors/>
<table width="100%"height="48" border="1"cellpadding="0"cellspacing="0"bordercolor="#FFFFFF"bordercolordark="#CCCCCC"bordercolorlight="#FFFFFF">
<tr bgcolor="#eeeeee">
<td width="22%" height="24"align="center"><b>名称</b></td>
<td width="11%"align="center"><b>数量</b></td>
<td width="40%"align="center"><b>收藏单位</b></td>
<td width="11%"align="center"><b>语言(0中:1外)</b></td>
<td width="8%"align="center"><b>修改</b></td>
<td width="8%"align="center"><b>删除</b></td> </tr>
<logic:iterate id="emps" name="kjwxs" >
<tr bgcolor="#FFFF88">
<td>
<bean:write name="emps" property="mingchen" /></td>
<td>
<bean:write name="emps" property="shuliang" /></td>
<td>
<bean:write name="emps" property="shoucangdanwei" /></td>
<td>
<bean:write name="emps" property="yuyan" /></td>
<td>
</tr>
</logic:iterate>
</table>
</center>
</body>
</html:html>
错误javax.servlet.ServletException: An error occurred while evaluating custom action attribute "value" with value "${kjwxBean.kjwxs}": An error occurred while getting property "kjwxs" from an instance of class bean.KjwxBean (java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid column name: mc)
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.manage.m_jsp._jspService(m_jsp.java:268)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
root cause javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "value" with value "${kjwxBean.kjwxs}": An error occurred while getting property "kjwxs" from an instance of class bean.KjwxBean (java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid column name: mc)
org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:146)
org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:166)
org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate(ExpressionEvaluatorManager.java:112)
org.apache.taglibs.standard.tag.el.core.ExpressionUtil.evalNotNull(ExpressionUtil.java:85)
org.apache.taglibs.standard.tag.el.core.SetTag.evaluateExpressions(SetTag.java:147)
org.apache.taglibs.standard.tag.el.core.SetTag.doStartTag(SetTag.java:95)
org.apache.jsp.manage.m_jsp._jspx_meth_c_set_0(m_jsp.java:285)
org.apache.jsp.manage.m_jsp._jspService(m_jsp.java:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
将tld文件里面set的value的rtx什么什么的由false改成true