struts JSP报错
xs.jsp<%@pagelanguage="java"pageEncoding="gb2312"%><%@tagliburi="http://struts.apache...
xs.jsp
<%@ page language="java" pageEncoding="gb2312"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%>
<html>
<head>
<title>JSP for XsForm form</title>
</head>
<body>
<html:form action="/xs">
name : <html:text property="name"/><html:errors property="name"/><br/>
<html:submit/><html:cancel/>
</html:form>
<logic:present name="al">
<logic:iterate id="t" name="al">
<logic:present name="t">
<bean:write name="al" property="id"/>
<bean:write name="al" property="name"/>
</logic:present>
</logic:iterate>
</logic:present>
<logic:notPresent name="al">
无记录</logic:notPresent>
</body>
</html>
package com.yourcompany.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.yourcompany.struts.form.XsForm;
import java.sql.*;
import java.util.*;
public class XsAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
XsForm xsForm = (XsForm) form;// TODO Auto-generated method stub
try{
java.lang.Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=XSCJ";
String user="sa";
String password="";
Connection con;
Statement sql;
ResultSet rs;
con=DriverManager.getConnection(url,user,password);
sql=con.createStatement();
//定义查询字符串
String s="select * from 学生基本信息表 where 姓名='"+bm(xsForm.getName())+"'";
rs=sql.executeQuery(s);
ArrayList al = new ArrayList();
while(rs.next())
{
XsForm XS =new XsForm();
XS.setId(rs.getString(1));
XS.setName(rs.getString(2));
al.add(XS);
}
request.setAttribute("al", al);
con.close();}
catch(Exception e)
{
System.out.print(e);
}
return mapping.findForward("XS");
}
public String bm(String s){
if(s==null){
s="";
}
try{
byte [] b = s.getBytes("iso-8859-1");
s = new String(b);
}catch(Exception e){
System.out.println(e);
}
return s;
}
}
报了org.apache.jasper.JasperException: An exception occurred processing JSP page /form/xs.jsp at line 17
14: <logic:present name="al">
15: <logic:iterate id="t" name="al">
16: <logic:present name="t">
17: <bean:write name="al" property="id"/>
18: <bean:write name="al" property="name"/>
19: </logic:present>
20: <logic:notPresent name="t"> 展开
<%@ page language="java" pageEncoding="gb2312"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%>
<html>
<head>
<title>JSP for XsForm form</title>
</head>
<body>
<html:form action="/xs">
name : <html:text property="name"/><html:errors property="name"/><br/>
<html:submit/><html:cancel/>
</html:form>
<logic:present name="al">
<logic:iterate id="t" name="al">
<logic:present name="t">
<bean:write name="al" property="id"/>
<bean:write name="al" property="name"/>
</logic:present>
</logic:iterate>
</logic:present>
<logic:notPresent name="al">
无记录</logic:notPresent>
</body>
</html>
package com.yourcompany.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.yourcompany.struts.form.XsForm;
import java.sql.*;
import java.util.*;
public class XsAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
XsForm xsForm = (XsForm) form;// TODO Auto-generated method stub
try{
java.lang.Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=XSCJ";
String user="sa";
String password="";
Connection con;
Statement sql;
ResultSet rs;
con=DriverManager.getConnection(url,user,password);
sql=con.createStatement();
//定义查询字符串
String s="select * from 学生基本信息表 where 姓名='"+bm(xsForm.getName())+"'";
rs=sql.executeQuery(s);
ArrayList al = new ArrayList();
while(rs.next())
{
XsForm XS =new XsForm();
XS.setId(rs.getString(1));
XS.setName(rs.getString(2));
al.add(XS);
}
request.setAttribute("al", al);
con.close();}
catch(Exception e)
{
System.out.print(e);
}
return mapping.findForward("XS");
}
public String bm(String s){
if(s==null){
s="";
}
try{
byte [] b = s.getBytes("iso-8859-1");
s = new String(b);
}catch(Exception e){
System.out.println(e);
}
return s;
}
}
报了org.apache.jasper.JasperException: An exception occurred processing JSP page /form/xs.jsp at line 17
14: <logic:present name="al">
15: <logic:iterate id="t" name="al">
16: <logic:present name="t">
17: <bean:write name="al" property="id"/>
18: <bean:write name="al" property="name"/>
19: </logic:present>
20: <logic:notPresent name="t"> 展开
3个回答
展开全部
<logic:present name="al">
15: <logic:iterate id="t" name="al">
16: <logic:present name="t">
17: <bean:write name="al" property="id"/>
18: <bean:write name="al" property="name"/>
改为
----------------------------------------------
17: <bean:write name="t" property="id"/>
18: <bean:write name="t" property="name"/>
----------------------------------------------
19: </logic:present>
20: <logic:notPresent name="t">
15: <logic:iterate id="t" name="al">
16: <logic:present name="t">
17: <bean:write name="al" property="id"/>
18: <bean:write name="al" property="name"/>
改为
----------------------------------------------
17: <bean:write name="t" property="id"/>
18: <bean:write name="t" property="name"/>
----------------------------------------------
19: </logic:present>
20: <logic:notPresent name="t">
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是不是没导包?
asp 页面好象没有加导入包的语句或者没有将 .java生成.class
asp 页面好象没有加导入包的语句或者没有将 .java生成.class
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询