Struts问题!

ynniebo 2004-08-24 03:21:14
本人现在在做一个Struts项目.由于刚学.所以有很多问题稿不明白.如果哪位大哥有自已做的Struts的例子.给我一分参考一下...内容要有一定的学心价值,还有就是要用到数据库处理的..有一定的注解....100分相送.近期佳音!

邮箱:ynniebo@163.com
...全文
230 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
ynniebo 2004-08-31
  • 打赏
  • 举报
回复
真的好意思....多谢这分老兄的贴子.....这些资料在网上我见到过....
idkkk 2004-08-31
  • 打赏
  • 举报
回复
具体还是看struts自己自带的例子吧,比较权威,挺不错的!
hary90 2004-08-31
  • 打赏
  • 举报
回复
马上email给你。
ynzhl 2004-08-31
  • 打赏
  • 举报
回复
本人现有一个例子,已经调试通过.我发给你吧!自己再好好的看看.OK!注意收啊.
刘大黑 2004-08-31
  • 打赏
  • 举报
回复
已经帮你调试好了,例子发给你了,请收邮件~
ynniebo 2004-08-30
  • 打赏
  • 举报
回复
有点有行啊....帮看一看这个问题吧.....
本人现在在做了一个测试程序.是从数据库里取出数据来显示到页面上...但是都不行..显示不了....请高手帮助指点指点...

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>
bluesky35 2004-08-27
  • 打赏
  • 举报
回复
我的QQ是81806701,现在在NEC,公司太严,不能上网,只有休息时间可以,但是不允许挂QQ,所以我只有晚上上,晚上10点以后.
ynniebo 2004-08-27
  • 打赏
  • 举报
回复
bluesky35(蓝天)你的QQ是多少,,能说出来我加一下你吗.....我的是125221808.还有些问题....想请教一下你.....
bluesky35 2004-08-26
  • 打赏
  • 举报
回复
很简单的例子,就是在login画面上输入用户名和密码,在对数据库进行核对后显示登录画面或拒绝登录画面。
bluesky35 2004-08-26
  • 打赏
  • 举报
回复
还有SQL Server 2000
bluesky35 2004-08-26
  • 打赏
  • 举报
回复
该demo在eclipse2.1.1+tomcat4.1.27+easystruts0.6.4下调试通过,环境配置请参照:

http://community.csdn.net/Expert/topic/2815/2815355.xml?temp=.203335
bluesky35 2004-08-26
  • 打赏
  • 举报
回复
不好意思,今天回家晚了,东西已经发出,请收一下。
maoerzuozuo 2004-08-26
  • 打赏
  • 举报
回复
也给俺一个啊~谢谢了!
molmd@163.net
molmd@163.com
meng@coolfull.com

谢谢
ynniebo 2004-08-26
  • 打赏
  • 举报
回复
多谢各位的支持!
bluesky35 2004-08-26
  • 打赏
  • 举报
回复
我有个很简单的专门针对初学者的例子,晚上回去发给你.你明天收信箱.
shangqiao 2004-08-26
  • 打赏
  • 举报
回复
94呀,下载的struts里面不是有例子嘛
caiyi0903 2004-08-26
  • 打赏
  • 举报
回复
struts自带的例子你研究过吗?
ynniebo 2004-08-26
  • 打赏
  • 举报
回复
bluesky35(蓝天) 你不是说发过来给我例子吗.怎么我没有收到啊.....
cccer 2004-08-26
  • 打赏
  • 举报
回复
up
ynniebo 2004-08-24
  • 打赏
  • 举报
回复
各位同仁.....具体的网址我有了...如果没有做好的.可以是下大一点的例子的下载网址
加载更多回复(2)

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧