Struts问题! http://dev.csdn.net/develop/article/27/27011.shtm......http://dev.csdn.net/develop/article/27/27224.shtm 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 struts自带的例子你研究过吗? 94呀,下载的struts里面不是有例子嘛 也给俺一个啊~谢谢了![email protected][email protected][email protected]谢谢 bluesky35(蓝天) 你不是说发过来给我例子吗.怎么我没有收到啊..... 该demo在eclipse2.1.1+tomcat4.1.27+easystruts0.6.4下调试通过,环境配置请参照:http://community.csdn.net/Expert/topic/2815/2815355.xml?temp=.203335 很简单的例子,就是在login画面上输入用户名和密码,在对数据库进行核对后显示登录画面或拒绝登录画面。 bluesky35(蓝天)你的QQ是多少,,能说出来我加一下你吗.....我的是125221808.还有些问题....想请教一下你..... 我的QQ是81806701,现在在NEC,公司太严,不能上网,只有休息时间可以,但是不允许挂QQ,所以我只有晚上上,晚上10点以后. 有点有行啊....帮看一看这个问题吧.....本人现在在做了一个测试程序.是从数据库里取出数据来显示到页面上...但是都不行..显示不了....请高手帮助指点指点...Bean文件Test.javapublic class Test { protected Integer id; /** name property */ protected String name; /** email property */ protected String address; /** email property */ protected String email; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } /** * Returns the name. * @return String */ public String getName() { return name; } /** * Set the name. * @param name The name to set */ public void setName(String name) { this.name = name; } /** * Returns the address. * @return String */ public String getAddress() { return address; } /** * Set the guide_type. * @param address The address to set */ public void setAddress(String address) { this.address = address; } /** * Returns the email. * @return String */ public String getEmail() { return email; } /** * Set the email. * @param email The email to set */ public void setEmail(String email) { this.email = email; }}Action文件TestListAction.javaimport 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.standarsys.struts.form.Test;import com.standarsys.util.Database;import javax.servlet.ServletException;import java.io.IOException;import java.util.ArrayList;import java.sql.*;/** * MyEclipse Struts * Creation date: 08-26-2004 * * XDoclet definition: * @struts:action scope="null" validate="true" */public class TestListAction extends Action { public ArrayList getTests() { ArrayList tests = new ArrayList(); Database db = new Database(); // 连接数据库的文件.下面是具体的方法.. try { ResultSet rs = null; db.getConnection(); rs = db.query("select * form test"); while(rs.next()) { Test test =new Test(); test.setId(new Integer(rs.getInt("id"))); test.setName(rs.getString("name")); test.setAddress(rs.getString("address")); test.setEmail(rs.getString("email")); tests.add(test); } } catch(SQLException e) { System.out.println(e.getMessage()); } finally { db.closeConnection(); } return tests; } public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String target = new String("success"); ArrayList tests = new ArrayList(); tests = this.getTests(); if(tests==null) { target = new String("add"); } else { request.setAttribute("tests",tests); } return mapping.findForward(target); }}用来显示的JSP页testlist.jsp<%@ page language="java" import="java.util.*" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %><%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><%--<jsp:useBean id="tests" scope="request" class="com.standarsys.struts.form.Test"/>--%><jsp:useBean id="tests" scope="request" class="java.util.ArrayList"/><html:html> <head> <title>test list</title> </head> <body> <html:errors /> <table width="650" border="0" cellspacing="0" cellpadding="0"> <tr align="left"> <th>id</th> <th>name</th> <th>address</th> <th>email</th> </tr> <!-- iterate over the results of the query --> <logic:iterate id="test" name="tests" scope="request"> <tr align="left"> <td> <bean:write name="test" property="id" /> </td> <td> <bean:write name="test" property="name" /> </td> <td> <bean:write name="test" property="address" /> </td> <td> <bean:write name="test" property="email" /> </td> </tr> </logic:iterate> <tr> <td colspan="7"> <hr> </td> </tr> </table> </body></html:html>struts-config.xml<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"><struts-config> <data-sources /> <form-beans > </form-beans> <global-exceptions /> <global-forwards> </global-forwards> <action-mappings > <action input="/form/testlist.jsp" path="/testList" scope="request" type="com.standarsys.struts.action.TestListAction" unknown="false" validate="true"> <forward name="success" path="/form/testlist.jsp" redirect="false" contextRelative="false" /> <forward name="add" path="/form/listtest.jsp" redirect="false" contextRelative="false" /> </action> </action-mappings> <controller bufferSize="4096" debug="0" locale="false" nocache="false" inputForward="false" /> <message-resources null="true" parameter="com.standarsys.struts.ApplicationResources" /></struts-config> 具体还是看struts自己自带的例子吧,比较权威,挺不错的! js动态添加元素时 IE浏览器很卡, 关于String类型转成固定类型的Date问题 明天面试,求救,急!!!!!!! 如何在SQLite中删除某一个表中所有内容? JAVA Web编程中Oracle SQL的调优及表、索引的设计和优化 Spring+hibernate 中如何执行sql语句操作???? 这种实例化的理解? j2ee 请问,怎样实现数据集的上下滚动,谢谢(我的代码,总是报错!!)!! struts这时一个什么玩艺? javassist问提 Struts问题dynamicJavascript设置成"false"或"true"是什么意思呢?
[email protected]
[email protected]
[email protected]谢谢
本人现在在做了一个测试程序.是从数据库里取出数据来显示到页面上...但是都不行..显示不了....请高手帮助指点指点...Bean文件Test.java
public class Test { protected Integer id;
/** name property */
protected String name; /** email property */
protected String address; /** email property */
protected String email; public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
/**
* Returns the name.
* @return String
*/
public String getName() {
return name;
} /**
* Set the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
} /**
* Returns the address.
* @return String
*/
public String getAddress() {
return address;
} /**
* Set the guide_type.
* @param address The address to set
*/
public void setAddress(String address) {
this.address = address;
} /**
* Returns the email.
* @return String
*/
public String getEmail() {
return email;
} /**
* Set the email.
* @param email The email to set
*/
public void setEmail(String email) {
this.email = email;
}
}Action文件TestListAction.java
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.standarsys.struts.form.Test;
import com.standarsys.util.Database;import javax.servlet.ServletException;
import java.io.IOException;
import java.util.ArrayList;
import java.sql.*;
/**
* MyEclipse Struts
* Creation date: 08-26-2004
*
* XDoclet definition:
* @struts:action scope="null" validate="true"
*/
public class TestListAction extends Action { public ArrayList getTests() {
ArrayList tests = new ArrayList();
Database db = new Database(); // 连接数据库的文件.下面是具体的方法..
try {
ResultSet rs = null;
db.getConnection();
rs = db.query("select * form test");
while(rs.next()) {
Test test =new Test();
test.setId(new Integer(rs.getInt("id")));
test.setName(rs.getString("name"));
test.setAddress(rs.getString("address"));
test.setEmail(rs.getString("email"));
tests.add(test);
}
}
catch(SQLException e) {
System.out.println(e.getMessage());
}
finally {
db.closeConnection();
}
return tests;
} public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
String target = new String("success");
ArrayList tests = new ArrayList();
tests = this.getTests();
if(tests==null) {
target = new String("add");
}
else {
request.setAttribute("tests",tests);
}
return mapping.findForward(target);
}}用来显示的JSP页testlist.jsp
<%@ page language="java" import="java.util.*" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><%--
<jsp:useBean id="tests" scope="request" class="com.standarsys.struts.form.Test"/>
--%><jsp:useBean id="tests" scope="request" class="java.util.ArrayList"/><html:html>
<head>
<title>test list</title>
</head>
<body>
<html:errors /> <table width="650"
border="0" cellspacing="0" cellpadding="0">
<tr align="left">
<th>id</th>
<th>name</th>
<th>address</th>
<th>email</th>
</tr>
<!-- iterate over the results of the query -->
<logic:iterate id="test" name="tests" scope="request">
<tr align="left">
<td>
<bean:write name="test" property="id" />
</td>
<td>
<bean:write name="test" property="name" />
</td>
<td>
<bean:write name="test" property="address" />
</td>
<td>
<bean:write name="test" property="email" />
</td>
</tr>
</logic:iterate>
<tr>
<td colspan="7">
<hr>
</td>
</tr>
</table>
</body>
</html:html>struts-config.xml<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<data-sources />
<form-beans >
</form-beans> <global-exceptions />
<global-forwards>
</global-forwards>
<action-mappings >
<action
input="/form/testlist.jsp"
path="/testList"
scope="request"
type="com.standarsys.struts.action.TestListAction"
unknown="false"
validate="true">
<forward
name="success"
path="/form/testlist.jsp"
redirect="false"
contextRelative="false" />
<forward
name="add"
path="/form/listtest.jsp"
redirect="false"
contextRelative="false" />
</action>
</action-mappings> <controller
bufferSize="4096"
debug="0"
locale="false"
nocache="false"
inputForward="false" />
<message-resources null="true" parameter="com.standarsys.struts.ApplicationResources" />
</struts-config>