<%@ page language="java" import="java.util.*,com.icss.vo.*" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'goodslist.jsp' starting page</title>
<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>
<form action="UserServlet" name="formlist" method="post">
<input type="hidden" name="opflag" value="">
<table border="0" >
<tr>
<td></td>
<td>商品名称</td>
<td>商品品牌</td>
<td>价格</td>
<td>人气</td>
<td>基本运费</td>
<td>描述</td>
</tr>
<%
request.setCharacterEncoding("GBK");
List<GoodsVo> goods=(List)request.getAttribute("goods");
if(goods!=null){
for(GoodsVo goodsvo:goods){
%>
<tr>
<td><%=goodsvo.getGoodsname() %></td>
<td><%=goodsvo.getBrand() %></td>
<td><%=goodsvo.getPrice()%></td>
<td><%=goodsvo.getStock()%></td>
<td><%=goodsvo.getBase_trans()%></td>
<td><%=goodsvo.getDescription()%></td>
</tr>
<%}
}%>
</table>
</form>
</body>
</html>
32 个解决方案
#1
s f
#2
#3
别沙发啊,给我看一下啊,郁闷一天了。
老提示:The type List is not generic; it cannot be parameterized with arguments
<GoodsVo>
为什么啊?
#4
别沙发啊,我郁闷一下午了,老提示:The type List is not generic; it cannot be parameterized with arguments
<GoodsVo>
快帮我瞅瞅,谢啦。
#5
老提示:The type List is not generic; it cannot be parameterized with arguments
<GoodsVo>
List不能那样用吗?帮帮我啊。
#6
在哪一行出异常,你把颜色标出来!
异常信息全贴出来!
异常信息全贴出来!
#7
List<GoodsVo> goods=(List<GoodsVo>)request.getAttribute("goods");
#8
List<GoodsVo> goods=(List)request.getAttribute("goods");
你改成:
List<GoodsVo> goods=(List<GoodsVo>)request.getAttribute("goods");
试试!
你改成:
List<GoodsVo> goods=(List<GoodsVo>)request.getAttribute("goods");
试试!
#9
<%
request.setCharacterEncoding("GBK");
List<GoodsVo> goods=(List)request.getAttribute("goods");
if(goods!=null){
for(GoodsVo goodsvo:goods){
%>
貌似是这几行。
#10
这个怎么样!
#11
我把所有流程都贴出来吧:
首先是在一个JSP输入:
<form action="UserServlet" method="post" name="mainsearch">
<td width=250px><font size="+1" color="#FF0000">站内搜索,输入商品关键字:</font></td>
<td width=300px>
<input type="text" name="goodsname" value="" maxlength="20">
<input type="hidden" name="opflag" value="query">
<input type="submit" name="Submit" value="搜索">
</td>
</tr>
</table>
</form>
数据库连接DbCon:
UserServlet中:
首先是在一个JSP输入:
<form action="UserServlet" method="post" name="mainsearch">
<td width=250px><font size="+1" color="#FF0000">站内搜索,输入商品关键字:</font></td>
<td width=300px>
<input type="text" name="goodsname" value="" maxlength="20">
<input type="hidden" name="opflag" value="query">
<input type="submit" name="Submit" value="搜索">
</td>
</tr>
</table>
</form>
数据库连接DbCon:
UserServlet中:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("GBK");
String opflag = request.getParameter("opflag");
if("query".equals(opflag)){
String goodsname = request.getParameter("goodsname");
String condi = "";
condi+="GOODS_NAME like '%"+goodsname+"%'";
UserDao userdao=new UserDao();
List goods=null;
try {
goods=userdao.query(condi);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setAttribute("goods",goods);
request.getRequestDispatcher("goodslist.jsp").forward(request,response);
}
}
#12
数据库连接:
package com.icss.base;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class DbCon {
public static Connection conn=null;
public static Statement st=null;
public void getCon() throws ClassNotFoundException, SQLException{
Class.forName("oracle.jdbc.driver.OracleDriver");//创建数据库驱动对象
conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:newtoe","test","test");//创建数据库连接对象
st=conn.createStatement();//创建执行sql语句对象
}
public void closeCon() throws SQLException{
if(st!=null){
st.close();
}
if(conn!=null){
conn.close();
}
}
/**
* @param args
*/
public void main(String[] args) {
DbCon dbc=new DbCon();
try {
dbc.getCon();
System.out.println(st);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
package com.icss.base;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class DbCon {
public static Connection conn=null;
public static Statement st=null;
public void getCon() throws ClassNotFoundException, SQLException{
Class.forName("oracle.jdbc.driver.OracleDriver");//创建数据库驱动对象
conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:newtoe","test","test");//创建数据库连接对象
st=conn.createStatement();//创建执行sql语句对象
}
public void closeCon() throws SQLException{
if(st!=null){
st.close();
}
if(conn!=null){
conn.close();
}
}
/**
* @param args
*/
public void main(String[] args) {
DbCon dbc=new DbCon();
try {
dbc.getCon();
System.out.println(st);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
#13
不行啊,试了。
#14
List goods=null;
定义时带上泛型定义
定义时带上泛型定义
#15
List<XXX> goods = new ArrayList<XXXX>();
#16
还有具体执行查询的这块:
public class UserDao extends DbCon{
public List query(String condi) throws ClassNotFoundException, SQLException {
getCon();
String sql="select * from GOODS_G where "+condi;
ResultSet rs=DbCon.st.executeQuery(sql);
List goods=new ArrayList();
while(rs.next()){
GoodsVo goodsvo=new GoodsVo();
goodsvo.setId(String.valueOf(rs.getInt("GOODS_ID")) );
goodsvo.setGoodsname(rs.getString("GOODS_NAME"));
goodsvo.setBrand(rs.getString("BRAND"));
goodsvo.setPrice(String.valueOf(rs.getInt("PRICE")));
goodsvo.setStock(String.valueOf(rs.getInt("STOCK")) );
goodsvo.setBase_trans(String.valueOf(rs.getInt("BASE_TRANS")) );
goodsvo.setDescription(rs.getString("DESCRIPTION"));
goods.add(goodsvo);
}
rs.close();
closeCon();
return goods;
}
}
#17
public List query(String condi) throws ClassNotFoundException, SQLException {
getCon();
String sql="select * from GOODS_G where "+condi;
ResultSet rs=DbCon.st.executeQuery(sql);
List goods=new ArrayList();
while(rs.next()){
定义时都带上泛型
返回定义时也带上
getCon();
String sql="select * from GOODS_G where "+condi;
ResultSet rs=DbCon.st.executeQuery(sql);
List goods=new ArrayList();
while(rs.next()){
定义时都带上泛型
返回定义时也带上
#18
还是这个,囧。。。
The type List is not generic; it cannot be parameterized with arguments
<GoodsVo>
#19
还是刚才那个提示,囧。。
#20
String condi = "";
condi+="GOODS_NAME like '%"+goodsname+"%'";
UserDao userdao=new UserDao();
List goods=null;
try {
goods=userdao.query( condi);
你往List里放的是什么类型!!!!
condi+="GOODS_NAME like '%"+goodsname+"%'";
UserDao userdao=new UserDao();
List goods=null;
try {
goods=userdao.query( condi);
你往List里放的是什么类型!!!!
#21
没事,看错了!
#22
等下给你全部重写了。麻烦!
#23
没提示啊,能具体点吗?
#24
GoodsVo这个类在jsp页面中导入了?
#25
public class UserDao extends DbCon{
public List<GoodsVo> query(String condi) throws ClassNotFoundException, SQLException {
getCon();
String sql="select * from GOODS_G where "+condi;
ResultSet rs=DbCon.st.executeQuery(sql);
List<GoodsVo> goods=new ArrayList<GoodsVo>();
GoodsVo goodsvo=null;
while(rs.next()){
goodsvo=new GoodsVo();
goodsvo.setId(String.valueOf(rs.getInt("GOODS_ID")) );
goodsvo.setGoodsname(rs.getString("GOODS_NAME"));
goodsvo.setBrand(rs.getString("BRAND"));
goodsvo.setPrice(String.valueOf(rs.getInt("PRICE")));
goodsvo.setStock(String.valueOf(rs.getInt("STOCK")) );
goodsvo.setBase_trans(String.valueOf(rs.getInt("BASE_TRANS")) );
goodsvo.setDescription(rs.getString("DESCRIPTION"));
goods.add(goodsvo);
}
rs.close();
closeCon();
return goods;
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("GBK");
String opflag = request.getParameter("opflag");
if("query".equals(opflag)){
String goodsname = request.getParameter("goodsname");
String condi = "";
condi+="GOODS_NAME like '%"+goodsname+"%'";
UserDao userdao=new UserDao();
List<GoodsVo> goods=null;
try {
goods=userdao.query(condi);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setAttribute("goods",goods);
request.getRequestDispatcher("goodslist.jsp").forward(request,response);
}
}
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<form action="UserServlet" name="formlist" method="post">
<input type="hidden" name="opflag" value="">
<table border="0" >
<tr>
<td></td>
<td>商品名称</td>
<td>商品品牌</td>
<td>价格</td>
<td>人气</td>
<td>基本运费</td>
<td>描述</td>
</tr>
<c:forEach item="goods" var="goodsvo">
<tr>
<td>${goodsvo.goodsname}</td>
<td>${goodsvo.brand}</td>
<td>${goodsvo.price}</td>
<td>${goodsvo.stock}</td>
<td>${goodsvo.base_trans}</td>
<td>${goodsvo.description}</td>
</tr>
</c:forEach>
</table>
</form>
</body>
</html>
#26
String sql="select * from GOODS_G where "+condi;
ResultSet rs=DbCon.st.executeQuery(sql);
List goods=new ArrayList();
#27
good luck!
#28
所有原来没加上<GoodsVo>的加上过后,全报错了,太邪恶了。。
#29
弄好了,谢谢大家,哈哈。。
#30
呵呵呵呵呵...
#31
#32
别讽我,才学没多久啊。
#1
s f
#2
#3
别沙发啊,给我看一下啊,郁闷一天了。
老提示:The type List is not generic; it cannot be parameterized with arguments
<GoodsVo>
为什么啊?
#4
别沙发啊,我郁闷一下午了,老提示:The type List is not generic; it cannot be parameterized with arguments
<GoodsVo>
快帮我瞅瞅,谢啦。
#5
老提示:The type List is not generic; it cannot be parameterized with arguments
<GoodsVo>
List不能那样用吗?帮帮我啊。
#6
在哪一行出异常,你把颜色标出来!
异常信息全贴出来!
异常信息全贴出来!
#7
List<GoodsVo> goods=(List<GoodsVo>)request.getAttribute("goods");
#8
List<GoodsVo> goods=(List)request.getAttribute("goods");
你改成:
List<GoodsVo> goods=(List<GoodsVo>)request.getAttribute("goods");
试试!
你改成:
List<GoodsVo> goods=(List<GoodsVo>)request.getAttribute("goods");
试试!
#9
<%
request.setCharacterEncoding("GBK");
List<GoodsVo> goods=(List)request.getAttribute("goods");
if(goods!=null){
for(GoodsVo goodsvo:goods){
%>
貌似是这几行。
#10
这个怎么样!
#11
我把所有流程都贴出来吧:
首先是在一个JSP输入:
<form action="UserServlet" method="post" name="mainsearch">
<td width=250px><font size="+1" color="#FF0000">站内搜索,输入商品关键字:</font></td>
<td width=300px>
<input type="text" name="goodsname" value="" maxlength="20">
<input type="hidden" name="opflag" value="query">
<input type="submit" name="Submit" value="搜索">
</td>
</tr>
</table>
</form>
数据库连接DbCon:
UserServlet中:
首先是在一个JSP输入:
<form action="UserServlet" method="post" name="mainsearch">
<td width=250px><font size="+1" color="#FF0000">站内搜索,输入商品关键字:</font></td>
<td width=300px>
<input type="text" name="goodsname" value="" maxlength="20">
<input type="hidden" name="opflag" value="query">
<input type="submit" name="Submit" value="搜索">
</td>
</tr>
</table>
</form>
数据库连接DbCon:
UserServlet中:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("GBK");
String opflag = request.getParameter("opflag");
if("query".equals(opflag)){
String goodsname = request.getParameter("goodsname");
String condi = "";
condi+="GOODS_NAME like '%"+goodsname+"%'";
UserDao userdao=new UserDao();
List goods=null;
try {
goods=userdao.query(condi);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setAttribute("goods",goods);
request.getRequestDispatcher("goodslist.jsp").forward(request,response);
}
}
#12
数据库连接:
package com.icss.base;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class DbCon {
public static Connection conn=null;
public static Statement st=null;
public void getCon() throws ClassNotFoundException, SQLException{
Class.forName("oracle.jdbc.driver.OracleDriver");//创建数据库驱动对象
conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:newtoe","test","test");//创建数据库连接对象
st=conn.createStatement();//创建执行sql语句对象
}
public void closeCon() throws SQLException{
if(st!=null){
st.close();
}
if(conn!=null){
conn.close();
}
}
/**
* @param args
*/
public void main(String[] args) {
DbCon dbc=new DbCon();
try {
dbc.getCon();
System.out.println(st);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
package com.icss.base;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class DbCon {
public static Connection conn=null;
public static Statement st=null;
public void getCon() throws ClassNotFoundException, SQLException{
Class.forName("oracle.jdbc.driver.OracleDriver");//创建数据库驱动对象
conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:newtoe","test","test");//创建数据库连接对象
st=conn.createStatement();//创建执行sql语句对象
}
public void closeCon() throws SQLException{
if(st!=null){
st.close();
}
if(conn!=null){
conn.close();
}
}
/**
* @param args
*/
public void main(String[] args) {
DbCon dbc=new DbCon();
try {
dbc.getCon();
System.out.println(st);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
#13
不行啊,试了。
#14
List goods=null;
定义时带上泛型定义
定义时带上泛型定义
#15
List<XXX> goods = new ArrayList<XXXX>();
#16
还有具体执行查询的这块:
public class UserDao extends DbCon{
public List query(String condi) throws ClassNotFoundException, SQLException {
getCon();
String sql="select * from GOODS_G where "+condi;
ResultSet rs=DbCon.st.executeQuery(sql);
List goods=new ArrayList();
while(rs.next()){
GoodsVo goodsvo=new GoodsVo();
goodsvo.setId(String.valueOf(rs.getInt("GOODS_ID")) );
goodsvo.setGoodsname(rs.getString("GOODS_NAME"));
goodsvo.setBrand(rs.getString("BRAND"));
goodsvo.setPrice(String.valueOf(rs.getInt("PRICE")));
goodsvo.setStock(String.valueOf(rs.getInt("STOCK")) );
goodsvo.setBase_trans(String.valueOf(rs.getInt("BASE_TRANS")) );
goodsvo.setDescription(rs.getString("DESCRIPTION"));
goods.add(goodsvo);
}
rs.close();
closeCon();
return goods;
}
}
#17
public List query(String condi) throws ClassNotFoundException, SQLException {
getCon();
String sql="select * from GOODS_G where "+condi;
ResultSet rs=DbCon.st.executeQuery(sql);
List goods=new ArrayList();
while(rs.next()){
定义时都带上泛型
返回定义时也带上
getCon();
String sql="select * from GOODS_G where "+condi;
ResultSet rs=DbCon.st.executeQuery(sql);
List goods=new ArrayList();
while(rs.next()){
定义时都带上泛型
返回定义时也带上
#18
还是这个,囧。。。
The type List is not generic; it cannot be parameterized with arguments
<GoodsVo>
#19
还是刚才那个提示,囧。。
#20
String condi = "";
condi+="GOODS_NAME like '%"+goodsname+"%'";
UserDao userdao=new UserDao();
List goods=null;
try {
goods=userdao.query( condi);
你往List里放的是什么类型!!!!
condi+="GOODS_NAME like '%"+goodsname+"%'";
UserDao userdao=new UserDao();
List goods=null;
try {
goods=userdao.query( condi);
你往List里放的是什么类型!!!!
#21
没事,看错了!
#22
等下给你全部重写了。麻烦!
#23
没提示啊,能具体点吗?
#24
GoodsVo这个类在jsp页面中导入了?
#25
public class UserDao extends DbCon{
public List<GoodsVo> query(String condi) throws ClassNotFoundException, SQLException {
getCon();
String sql="select * from GOODS_G where "+condi;
ResultSet rs=DbCon.st.executeQuery(sql);
List<GoodsVo> goods=new ArrayList<GoodsVo>();
GoodsVo goodsvo=null;
while(rs.next()){
goodsvo=new GoodsVo();
goodsvo.setId(String.valueOf(rs.getInt("GOODS_ID")) );
goodsvo.setGoodsname(rs.getString("GOODS_NAME"));
goodsvo.setBrand(rs.getString("BRAND"));
goodsvo.setPrice(String.valueOf(rs.getInt("PRICE")));
goodsvo.setStock(String.valueOf(rs.getInt("STOCK")) );
goodsvo.setBase_trans(String.valueOf(rs.getInt("BASE_TRANS")) );
goodsvo.setDescription(rs.getString("DESCRIPTION"));
goods.add(goodsvo);
}
rs.close();
closeCon();
return goods;
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("GBK");
String opflag = request.getParameter("opflag");
if("query".equals(opflag)){
String goodsname = request.getParameter("goodsname");
String condi = "";
condi+="GOODS_NAME like '%"+goodsname+"%'";
UserDao userdao=new UserDao();
List<GoodsVo> goods=null;
try {
goods=userdao.query(condi);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setAttribute("goods",goods);
request.getRequestDispatcher("goodslist.jsp").forward(request,response);
}
}
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<form action="UserServlet" name="formlist" method="post">
<input type="hidden" name="opflag" value="">
<table border="0" >
<tr>
<td></td>
<td>商品名称</td>
<td>商品品牌</td>
<td>价格</td>
<td>人气</td>
<td>基本运费</td>
<td>描述</td>
</tr>
<c:forEach item="goods" var="goodsvo">
<tr>
<td>${goodsvo.goodsname}</td>
<td>${goodsvo.brand}</td>
<td>${goodsvo.price}</td>
<td>${goodsvo.stock}</td>
<td>${goodsvo.base_trans}</td>
<td>${goodsvo.description}</td>
</tr>
</c:forEach>
</table>
</form>
</body>
</html>
#26
String sql="select * from GOODS_G where "+condi;
ResultSet rs=DbCon.st.executeQuery(sql);
List goods=new ArrayList();
#27
good luck!
#28
所有原来没加上<GoodsVo>的加上过后,全报错了,太邪恶了。。
#29
弄好了,谢谢大家,哈哈。。
#30
呵呵呵呵呵...
#31
#32
别讽我,才学没多久啊。