
正文
bbs论坛java代码 论坛系统源码java
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
如何用Java制作bbs?急~~
1.建立好数据库
2.在MyEclipse中,建立web项目,把项目部署在服务器(Tomcat)上,把数据库连到项目中
3.在网上下载一个bbs的静态页面, 把它粘贴到web项目中,修改其属性,使其变为jsp文件
4.在web项目中,封装一个连接数据库的类
5.在修改好的jsp文件中,通过递归方法,容器,等把帖子放入容器中,在相关代码处(就是展现帖子的html),通过Iterator再把相关主题贴,回复帖子的主题拿出来,通过参数传递id,超级连接的方式,回复帖子的主题连接到回复帖子的详细内容
只能大致说这么多了,你 可以到网上搜源代码
相关问答
Q1: 基于java的BBS论坛系统的设计与实现
对于编写基于Java的BBS论坛系统, 首先要确定你的框架与开发环境, 需要考虑如下问题
选用什么数据库 mysql还是sqlserver
选用什么开发环境eclipse还是idea
选用设么技术框架, 原生jsp还是springboot还是springmvc+mybaits
然后设计你的数据库, 搭建项目脚手架, 跑通你的javaweb系统
然后开始实现controller层, dao层, service层, jsp页面代码
我最近写的几个论坛系统都是这样设计的, 希望能够帮助你
Q2: 如何用Java实现模拟登录Discuz!论坛并下载返回的html代码?
package org.shaw;
import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
public class BaiyouBBS {
static final String LOGON_SITE = "";
static final int LOGON_PORT = 80;
public Cookie[] login(String name, String pas) {
try {
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT);
PostMethod post = new PostMethod("/logging.php?action=login");
client.executeMethod(post);
String responseString = new String(post.getResponseBody(), "gbk");
post.releaseConnection();
String formhash = getFormHash(responseString);
System.out.println(formhash);
post = new PostMethod("/logging.php?action=login");
NameValuePair[] params = new NameValuePair[11];
params[0] = new NameValuePair("loginfield", "username");
params[1] = new NameValuePair("username", name);
params[2] = new NameValuePair("password", pas);
params[3] = new NameValuePair("referer", "index.php");
params[4] = new NameValuePair("questionid", "0");
params[5] = new NameValuePair("answer", "");
params[6] = new NameValuePair("cookietime", "2592000");
params[7] = new NameValuePair("formhash", formhash);
params[8] = new NameValuePair("loginmode", "");
params[9] = new NameValuePair("loginsubmit", "true");
params[10] = new NameValuePair("styleid", "");
post.setRequestBody(params);
client.executeMethod(post);
// responseString = new String(post.getResponseBody(), "gbk");
post.releaseConnection();
GetMethod get = new GetMethod("/index.php");
client.executeMethod(get);
responseString = new String(get.getResponseBody(), "gbk");
get.releaseConnection();
System.out.println(responseString);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public String getFormHash(String htmlContent) {
try {
int start = htmlContent.indexOf("name=\"formhash\"");
start = htmlContent.indexOf("value=\"", start) + 7;
int end = htmlContent.indexOf("\"", start);
String formhash = htmlContent.substring(start, end);
return formhash;
} catch (RuntimeException e) {
throw e;
}
}
public static void main(String[] args) {
new BaiyouBBS().login("zzzxxxzzz", "zzzxxxzzz");
}
}
关于bbs论坛java代码和论坛系统源码java的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






