基于servlet的技术问答网站系统实现

Java知音_ Java知音_     2022-08-28     321

关键词:

这一篇博客将详细介绍一个基于Servlet的问答网站的实现,有详细的代码。

可能篇幅较长,以代码为主,有兴趣的童鞋看完可以尝试动手搭建一个属于自己的问答社区。

工具:Eclipse,数据库用到了MySQL,这次项目中未使用jsp,全部以Servlet注解的方式连接HTML和Servlet,JDK最好使用1.8,tomcat使用8.0。(注解方式为JDK1.5后的特性,最低要求1.5+,本项目使用JDK1.8)。

在这篇博客中可以学习到:

1,Servlet中关于注解的使用,本项目没有使用到传统的Servlet配置web.xml,全部使用注解的形式。

2,了解Font Awesome这一矢量图标库的使用,他基本提供了项目中所要使用到的所有图标,方便,快捷。

3,了解simditor这一富文本编辑器的使用,网站中直接嵌入富文本编辑器,再也不用为读取出来的文字格式不对发愁了。

4,关于项目中如何加入验证码,数据库查询之前先进行验证码验证。

5,关于MVC框架显示层——Velocity技术的使用。

先看一下大体项目图(由于主要做后台,前台可能略丑,大家可以自行找网站模板)


登录界面:


注册界面:



首页,展示了大家的提问:



解答界面,点击别人的提问后进入解答界面,使用了富文本编辑器。



我的解答界面,展示了我回答的历史:


我的提问界面,展示了我提问的所有问题:


提问界面:进入网站点击我要提问,加入当前页编辑问题:



下面介绍主要代码(代码中加入了详细注释,所以不再做说明)

主页列表Servlet:

@WebServlet( "/list.do" )
public class ListServlet  extends HttpServlet {
	private static final long serialVersionUID = 810339694607399128L;
	@Override
	protected void service( HttpServletRequest request , HttpServletResponse response )
			throws ServletException, IOException {
	String question=request.getParameter("quest");
	System.out.println(question);
	if(StringHelper.notEmpty(question)){
		final String SQL = "SELECT id , title ,content, publish_time , publish_ip , user_id FROM t_topic where title =? " ;
		ResultSet rs = JdbcHelper.query( SQL,question );
			// 创建一个 List 对象,用来保存一批 Topic 对象
		final List<Topic> topics = new ArrayList<>();
		try {
			// 每循环一次,光标下移一行,如果该行有数据返回 true
			while( rs.next() ){
				Topic t = new Topic(); // 创建对象
				t.setId( rs.getInt( 1 ) ); // 将 结果集 中的 该行数据 封装到 t 对象的 id 属性中
				t.setTitle( rs.getString( 2 ) );
				t.setContent(rs.getString(3));
				t.setPublishTime( rs.getTimestamp( 4 ));
				t.setPublishIp( rs.getString( 5 ) );
				User u = new User(); // 创建 一个 User 对象
				u.setId( rs.getInt( 6 ) ); // 将 t_topic 表中的 user_id 放入到 User 对象的 id 属性中
				t.setUser( u );  // 将 User 对象 设置到 Topic 对象上
				/** 将 本次循环 创建的对象(已经封装数据) 添加到 List 集合中 */
				topics.add( t );
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
			JdbcHelper.release( rs ); // 关闭 结果集,释放相关的资源
			/**** 为每个问题寻找提问者  ***********************************/
			//for( int i = 0 ; i < topics.size() ; i++ ){
			for( int i = 0 , len = topics.size() ; i < len ; i++ ){
				Topic t = topics.get( i ) ; // 获得 题目
				User u = t.getUser(); // 获得当前题目的User对象 ( 该对象中只有 id 没有其它数据 )
				// 根据 用户对象的 id 来查询 用户的信息
				String querySQL = "SELECT id , username , password FROM t_user WHERE id = ? " ;
				ResultSet userRs = JdbcHelper.query( querySQL , u.getId() );
				try {
					if( userRs.next() ) { // 如果查询到用户信息
						// 注意,这里应该使用 userRs
						u.setUsername( userRs.getString( 2 ) ); // 将 username 列的值设置到 用户对象的 username 属性中
						u.setPassword( userRs.getString( 3 )); // 将 password 列的值设置到 用户对象的 password 属性中
					}
				} catch (SQLException e) {
					e.printStackTrace();
				}
				JdbcHelper.release( userRs ); // 关闭 结果集,释放相关的资源
			}
			ServletContext application = request.getServletContext();
			/** 将这些数据保存到 application **/
			application.setAttribute( "topics" , topics );
			System.out.println( "问题列表: " + topics );
			// 去 list.html 页面
			response.sendRedirect( request.getContextPath() + "/list.html");
		}else{
		    /**** 查询数据库中的所有问题  ***********************************/
			final String SQL = "SELECT id , title ,content ,publish_time , publish_ip , user_id FROM t_topic ORDER BY publish_time DESC" ;
			ResultSet rs = JdbcHelper.query( SQL );
			// 创建一个 List 对象,用来保存一批 Topic 对象
			final List<Topic> topics = new ArrayList<>();
			try {
				// 每循环一次,光标下移一行,如果该行有数据返回 true
				while( rs.next() ){
					Topic t = new Topic(); // 创建对象
					t.setId( rs.getInt( 1 ) ); // 将 结果集 中的 该行数据 封装到 t 对象的 id 属性中
					t.setTitle( rs.getString( 2 ) );
					t.setContent(rs.getString(3));
					t.setPublishTime( rs.getTimestamp( 4 ));
					t.setPublishIp( rs.getString( 5 ) );
					User u = new User(); // 创建 一个 User 对象
					u.setId( rs.getInt( 6) ); // 将 t_topic 表中的 user_id 放入到 User 对象的 id 属性中
					t.setUser( u );  // 将 User 对象 设置到 Topic 对象上
					/** 将 本次循环 创建的对象(已经封装数据) 添加到 List 集合中 */
					topics.add( t );
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
			JdbcHelper.release( rs ); // 关闭 结果集,释放相关的资源
			/**** 为每个问题寻找提问者  ***********************************/
			//for( int i = 0 ; i < topics.size() ; i++ ){
			for( int i = 0 , len = topics.size() ; i < len ; i++ ){
				Topic t = topics.get( i ) ; // 获得 题目
				User u = t.getUser(); // 获得当前题目的User对象 ( 该对象中只有 id 没有其它数据 )
				// 根据 用户对象的 id 来查询 用户的信息
				String querySQL = "SELECT id , username , password FROM t_user WHERE id = ? " ;
				ResultSet userRs = JdbcHelper.query( querySQL , u.getId() );
				try {
					if( userRs.next() ) { // 如果查询到用户信息
						// 注意,这里应该使用 userRs
						u.setUsername( userRs.getString( 2 ) ); // 将 username 列的值设置到 用户对象的 username 属性中
						u.setPassword( userRs.getString( 3 )); // 将 password 列的值设置到 用户对象的 password 属性中
					}
				} catch (SQLException e) {
					e.printStackTrace();
				}
				JdbcHelper.release( userRs ); // 关闭 结果集,释放相关的资源
			}
			ServletContext application = request.getServletContext();
			/** 将这些数据保存到 application **/
			application.setAttribute( "topics" , topics );
			System.out.println( "问题列表: " + topics );
			// 去 list.html 页面
			response.sendRedirect( request.getContextPath() + "/list.html");
	}
	}
}

主页列表显示界面代码:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>首页</title>
	    <link rel="stylesheet" href="$path/styles/general.css">
	    <link rel="stylesheet" href="$path/styles/cell.css">
	    <link rel="stylesheet" href="$path/styles/wen.css">
	</head>
	<body>
	
		## 登录状态栏 开始
		<div class="login-status-container  auto-height">
				<span class="welcome cell-8">
					## 在 $ 之后 表达式之前使用 ! 表示 安静模式 ( 静默模式 )
					<b>欢迎$!user.username来到爱问社区</b>
				</span>
				<span class="login-operation cell-4">
					#if( $user )
						<a href="$path/ask.html">提问</a>
						<em>|</em>
						<a href="$path/myQuestion.do">我的提问</a>
						<em>|</em>
						<a href="$path/logout.do">注销</a>
					#else
						<a href="$path/login.html">登录</a>
						<em>|</em>
						<a href="$path/regist.html">注册</a>
					#end
				</span>
		</div> ## 登录状态栏 结束
		
		## 标志区域
		<div class="brand-container  auto-height">
			<div class="cell-2">
				<a href="$path"></a>
			</div>
			<div class="slogan cell-10">
				<div>
				爱问社区,这里可放logo
				</div>
			</div>
		</div>
		
		## 列表区域
		<div class="topic-list-container clear">
			<!-- 问题列表的标题 -->
			<div class="topic-list-header row clear">
				<span class="topic-item-index cell-1">序号</span>
				<span class="topic-item-title cell-5" style="text-align: left ;">标题</span>
				<span class="topic-item-time cell-3">提问时间</span>
				<span class="topic-item-user cell-2">提问者</span>
				<span class="topic-item-operation cell-1">
					#if( $user )
						解答问题
					#end
				</span>
			</div>

				## 问题列表开始
					##  每循环一次从 $topics 集合中取出一个 Topic 对象 放到 $topic 中
					#foreach( $topic in $topics )
			
					<div class="topic-item row clear odd">
							<span class="topic-item-index cell-1">$topic.id</span>
							<span class="topic-item-title cell-5" style="text-align: left ;">
								<a href="$path/detail.do?id=$topic.id">$topic.title</a>
							</span>
							<span class="topic-item-time cell-3"> $topic.publishTime </span>
							<span class="topic-item-user cell-2"> $topic.user.username</span>
							<span class="topic-item-operation cell-1"> 
								#if( $user )
									<a href="$path/answer.do?id=$topic.id">解答</a>
								#end
							</span>
					</div>
					
		
				#end
			## 问题列表结束
			
		</div>## 列表区域结束
		
		<div class="line"></div>
		
		<div class="container link-container">
		    <a href="$path/ask.html" >发起新问题</a>
		    |
		    <a href="$path/index.html" >返回首页</a>
		</div>
		
		<div class="container copyright-container">
		    &copy; 2017 爱问社区版权所有
		</div>
	
	</body>
</html>

提问Servlet处理代码(对用户进行了过滤,未登录用户不能发起提问)

@WebServlet( "/ask.do" )
public class AskServlet   extends HttpServlet {

	private static final long serialVersionUID = -4777642507114213231L;

	@Override
	protected void service( HttpServletRequest request , HttpServletResponse response ) 
			throws ServletException, IOException {
		
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute( "user" ); // 在登录时将 User 对象放入了 会话 中
		
		// 先检查用户是否已经登录 ( 看 会话 中是否 拥有 User 对象 )
		if( user != null ) {
			// 接受来自页面的数据
			String title = request.getParameter( "title" );
			String content = request.getParameter( "content" );
			
			System.out.println( "title : " + title );
			System.out.println( "content : " + content );
			
			// 判断 title 和 content 是否不为 空 ( 不等于 null 不是空白字符串, 也不是空串)
			if( StringHelper.notEmpty( title ) && StringHelper.notEmpty( content ) ){
				// 获得 客户端 的 IP 地址
				String ip = request.getRemoteAddr();
				System.out.println( "ip : " + ip );
				
				// 获得 从 历元 到当前时刻所经历的毫米数
				long ms = System.currentTimeMillis();
				Timestamp currentTime = new Timestamp( ms ) ;
				
				final String SQL = "INSERT INTO t_topic ( title , content , publish_time , publish_ip , user_id ) VALUES ( ? , ? , ? , ? , ? )" ;
				int n = JdbcHelper.insert(SQL, false, title , content , currentTime , ip ,  user.getId() );
				
				if( n > 0 ){
					// 如果提问成功,则去往列表页面
					response.sendRedirect( request.getContextPath() + "/list.do" );
				} else {
					// 用户已经登录了,但是没有填入 title 和 content
					session.setAttribute( "askFail" , "提问失败了" );
					response.sendRedirect( request.getContextPath() + "/ask.html" );
				}
				
			} else {
				// 用户已经登录了,但是没有填入 title 和 content
				session.setAttribute( "askFail" , "标题和内容都不能为空" );
				response.sendRedirect( request.getContextPath() + "/ask.html" );
			}
		
		} else {
			// 用户没有登录,需要给出提示并回到登录页面去
			session.setAttribute( "loginFail" , "没有登录不能提问,请先登录" );
			response.sendRedirect( request.getContextPath() + "/login.html" );
		}
		
	}

}

提问前台界面代码:

<!DOCTYPE html>

<html>
	<head>
		<meta charset="UTF-8">
		<title>提问</title>
	    <link rel="stylesheet" href="$path/styles/general.css">
	    <link rel="stylesheet" href="$path/styles/cell.css">
	    <link rel="stylesheet" href="$path/styles/wen.css">
	    <link rel="stylesheet" href="$path/styles/btn.css">
	    
	    <!-- 链接 simditor 的样式库 -->
	   	<link rel="stylesheet"  href="$path/simditor/styles/simditor.css" type="text/css">
		<!-- 导入 simditor 的 JavaScript 库 -->
		<script type="text/javascript" src="$path/simditor/scripts/jquery.min.js"></script>
		<script type="text/javascript" src="$path/simditor/scripts/module.js"></script>
		<script type="text/javascript" src="$path/simditor/scripts/hotkeys.js"></script>
		<script type="text/javascript" src="$path/simditor/scripts/uploader.js"></script>
		<script type="text/javascript" src="$path/simditor/scripts/simditor.min.js"></script>
	    
	</head>
	<body>
	
		## 登录状态栏 开始
		<div class="id="topnav" class="f_r">
				<span class="welcome cell-8">
					## 在 $ 之后 表达式之前使用 ! 表示 安静模式 ( 静默模式 )
					<b>欢迎$!user.username来到爱问社区</b>
				</span>
				<span class="login-operation cell-4">
					#if( $user )
						<a href="$path/ask.html">提问</a>
						<em>|</em>
						<a href="$path/myQuestion.do">我的提问</a>
						<em>|</em>
						<a href="$path/logout.do">注销</a>
					#else
						<a href="$path/login.html">登录</a>
						<em>|</em>
						<a href="$path/regist.html">注册</a>
					#end
				</span>
		</div> ## 登录状态栏 结束
		
		<div class="brand-container  auto-height">
			<div class="cell-2">
				<a href="$path"></a>
			</div>
			<div class="slogan cell-10">
				<div>
				爱问社区,这里可以logo
				</div>
			</div>
		</div>
		
		<div class="container message-container">
		    <!-- 显示提示信息的地方 -->
		    #if( $askFail ) 
		   		$askFail
		   		$scope.remove( $session , 'askFail' )
		    #end
		</div>
		
		#if( $user ) 
		<!-- 提问表单 提交给 ask.do 对应的 Servlet 处理  -->
		<form action="$path/ask.do" method="post" >
		<!-- 提问区域 开始 -->
		<div class="container  topic-ask-container clear shadow-outside auto-height" >
			<!-- 问题的标题 和 提问按钮 -->
			<div class="container  title-container">
				<div class="cell-11">
					<input type="text" name="title" placeholder="请输入你要提问的问题的标题" class="u-ipt">
				</div>
				<div class="cell-1">
					<input type="submit" value="提问" class="u-btn u-btn-c4">
				</div>
			</div>
			
			<div class="line"></div>
			
			<!-- 问题的内容 -->
			<div>
				<textarea name="content" id="contentEditor" ></textarea>
				<script type="text/javascript" >
					var editor = new Simditor( {
						textarea : $('#contentEditor'),
						placeholder : '请在这里输入问题的内容...',
						toolbar : true 
					} );
				</script>
			</div>
			
			<div class="line"></div>
			
			<!-- 最底部的提问按钮 -->
			<div class="container  title-container">
				<div class="cell-11" style="height: 1px ;"></div>
				<div class="cell-1">
					<input type="submit" value="提问" class="u-btn u-btn-c4">
				</div>
			</div>
		</div> <!-- 提问区域 结束 -->
		</form>
		#else
			<div style="text-align:center ; min-height: 400px ; line-height: 400px ;">
				登录以后才能发起提问,请<a href="$path/login.html" >登录</a>
			</div>
		#end
		
		<div class="line"></div>
		
		<div class="container link-container">
		    <a href="$path/list.do" >问题列表</a>
		    |
		    <a href="$path/index.html" >返回首页</a>
		</div>
		
		<div class="container copyright-container">
		    &copy; 2017 爱问社区版权所有
		</div>
		
	</body>
</html>

回答Servlet处理代码:

@WebServlet("/answer.do")
public class AnswerServlet extends HttpServlet {

	private static final long serialVersionUID = 8578962149437664830L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		// 从 请求中获得请求参数的值
		String id = request.getParameter("id");

		if (StringHelper.notEmpty(id)) {

			try {
				int topicId = Integer.parseInt(id); // 将字符串按照 十进制 解析问 int 类型数值

				// 根据得到的 问题的 主键 查询数据库,得到 详细信息
				final String SQL = "SELECT  id , title , content , publish_time , publish_ip , user_id  FROM t_topic WHERE id = ? ";

				ResultSet rs = JdbcHelper.query(SQL, topicId);

				Topic t = null;
				int userId = -1;

				if (rs.next()) { // 当 根据 问题的主键 获取到 问题信息时
					t = new Topic(); // 创建 Topic 对象

					t.setId(rs.getInt(1)); // 将 结果集 中的 该行数据 封装到 t 对象的 id 属性中
					t.setTitle(rs.getString(2));
					t.setContent(rs.getString(3));
					t.setPublishTime(rs.getTimestamp(4));
					t.setPublishIp(rs.getString(5));

					userId = rs.getInt(6);
				}

				JdbcHelper.release(rs); // 关闭结果集

				// 获得提问者
				final String getUserSQL = "SELECT id , username , password FROM t_user WHERE id = ? ";
				rs = JdbcHelper.query(getUserSQL, userId);
				if (userId != -1 && rs.next()) {
					User u = new User();
					// 封装数据
					u.setId(rs.getInt(1));
					u.setUsername(rs.getString(2));
					u.setPassword(rs.getString(3));
					// 将获取到的用户数据设置到 Topic 对象的 user 属性中
					t.setUser(u);
				}

				HttpSession session = request.getSession();
				session.setAttribute("topic", t);

				response.sendRedirect(request.getContextPath() + "/answer.html");

				return; // 让方法立即结束
			} catch (NumberFormatException e) {
				e.printStackTrace();
				// response.sendRedirect( request.getContextPath() + "/list.do" );
			} catch (SQLException e) {
				e.printStackTrace();
				// response.sendRedirect( request.getContextPath() + "/list.do" );
			}

		} else {
			// response.sendRedirect( request.getContextPath() + "/list.do" );
		}

		response.sendRedirect(request.getContextPath() + "/list.do");

	}

}


回答前台代码:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>解答: $topic.title</title>
	    <link rel="stylesheet" href="$path/styles/general.css">
	    <link rel="stylesheet" href="$path/styles/cell.css">
	    <link rel="stylesheet" href="$path/styles/wen.css">
	    
	    <!-- 链接 simditor 的样式库 -->
	   	<link rel="stylesheet"  href="$path/simditor/styles/simditor.css" type="text/css">
		<!-- 导入 simditor 的 JavaScript 库 -->
		<script type="text/javascript" src="$path/simditor/scripts/jquery.min.js"></script>
		<script type="text/javascript" src="$path/simditor/scripts/module.js"></script>
		<script type="text/javascript" src="$path/simditor/scripts/hotkeys.js"></script>
		<script type="text/javascript" src="$path/simditor/scripts/uploader.js"></script>
		<script type="text/javascript" src="$path/simditor/scripts/simditor.min.js"></script>
		
	</head>
	<body>
	
		## 登录状态栏 开始
		<div class="login-status-container  auto-height">
				<span class="welcome cell-8">
					## 在 $ 之后 表达式之前使用 ! 表示 安静模式 ( 静默模式 )
					<b>欢迎$!user.username来到爱问社区</b>
				</span>
				<span class="login-operation cell-4">
					#if( $user )
						<a href="$path/ask.html">提问</a>
						<em>|</em>
						<a href="">我的提问</a>
						<em>|</em>
						<a href="$path/logout.do">注销</a>
					#else
						<a href="$path/login.html">登录</a>
						<em>|</em>
						<a href="$path/regist.html">注册</a>
					#end
				</span>
		</div> ## 登录状态栏 结束
		
		## 标志区域
		<div class="brand-container  auto-height">
			<div class="logo cell-2">
				<a href="$path"></a>
			</div>
			<div class="slogan cell-10">
				<div>
				解答问题
				</div>
			</div>
		</div>
		
			<div>
				<h3>$topic.title</h3>
				<div class="line"></div>
				<div>
					$topic.content
				</div>
				<div>
					提问时间: $topic.publishTime / 提问者: $topic.user.username
				</div>
			</div>
			
			<!-- 解答的内容 -->
			<form action="$path/explain.do" method="post" >
				<input type="hidden" name="id" value="$topic.id" >
			<div>
				<textarea name="content" id="contentEditor" ></textarea>
				<script type="text/javascript" >
					var editor = new Simditor( {
						textarea : $('#contentEditor'),
						placeholder : '请在这里输入问题的内容...',
						toolbar : true 
					} );
				</script>
			</div>
			<input type="submit" value="提交解答">
			</form>
		
		
		
		$scope.remove( $session , 'topic' );
		
		<div class="line"></div>
		
		<div class="container link-container">
		    <a href="$path/ask.html" >发起新问题</a>
		    |
		    <a href="$path/index.html" >返回首页</a>
		</div>
		
		<div class="container copyright-container">
		    &copy; 2017 爱问社区版权所有
		</div>
	
	</body>
</html>


以下是使用simditor的方法,需要引入simditor中的css和js样式。simditor下载地址:http://download.csdn.net/detail/weixin_36380516/9813448
<textarea name="content" id="contentEditor" ></textarea>
				<script type="text/javascript" >
					var editor = new Simditor( {
						textarea : $('#contentEditor'),
						placeholder : '请在这里输入问题的内容...',
						toolbar : true 
					} );
				</script>


解答问题Servlet处理,这里需要获取提问者,提问问题以及该问题的已有答案,已有答案回答者。

@WebServlet("/detail.do")
public class DetailServlet extends HttpServlet {
    private static final long serialVersionUID = -3202278077673657729L;
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
	    throws ServletException, IOException {
	// 从 请求中获得请求参数的值
	String id = request.getParameter("id");
	if (StringHelper.notEmpty(id)) {
	    try {
		int topicId = Integer.parseInt(id); // 将字符串按照 十进制 解析问 int 类型数值
		// 根据得到的 问题的 主键 查询数据库,得到 详细信息
		final String SQL = "SELECT  id , title , content , publish_time , publish_ip , user_id  FROM t_topic WHERE id = ? ";
		ResultSet rs = JdbcHelper.query(SQL, topicId);
		Topic t = null;
		/*int userId = -1;*/
		if (rs.next()) { // 当 根据 问题的主键 获取到 问题信息时
		    t = new Topic(); // 创建 Topic 对象
		    t.setId(rs.getInt(1)); // 将 结果集 中的 该行数据 封装到 t 对象的 id 属性中
		    t.setTitle(rs.getString(2));
		    t.setContent(rs.getString(3));
		    t.setPublishTime(rs.getTimestamp(4));
		    t.setPublishIp(rs.getString(5));
		    User user = new User();
		    user.setId(rs.getInt(6));
		    t.setUser(user);
		}
		JdbcHelper.release(rs); // 关闭结果集
		// 获得提问者
		final String getUserSQL = "SELECT id , username , password FROM t_user WHERE id = ? ";
		rs = JdbcHelper.query(getUserSQL, t.getUser().getId());
		if(rs.next()) 
		{
		    User u = new User();
		    // 封装数据
		    u.setId(rs.getInt(1));
		    u.setUsername(rs.getString(2));
		    u.setPassword(rs.getString(3));
		    // 将获取到的用户数据设置到 Topic 对象的 user 属性中
		    t.setUser(u);
		    System.out.println("message username:" + rs.getString(2));
		}
		JdbcHelper.release(rs); // 关闭结果集
		// 获得当前的问题的所有解答
		String explainSQL = "SELECT  id , content , explain_time , explain_ip , user_id  from t_explain where topic_id = ? ";
		rs = JdbcHelper.query(explainSQL, topicId);
		@SuppressWarnings("unused")
		int explainerId = -1;
		List<Explain> explains = new ArrayList<>();
		while (rs.next()) {
		    Explain e = new Explain();
		    e.setId(rs.getInt(1));
		    e.setContent(rs.getString(2));
		    e.setExplainTime(rs.getTimestamp(3));
		    e.setExplainIp(rs.getString(4));
		    User user=new User();
		    user.setId(rs.getInt(5));
		    e.setUser(user);
		    explains.add(e);
		    System.out.println("explain userID:" + rs.getInt(5));
		}
		// 获得解答者
		List<Explain>explainList = new ArrayList();
		for(int i=0;i<explains.size();i++)
		{
		    Explain explain1 = explains.get(i);
		    final String getExplainerSQL = "SELECT id , username , password FROM t_user WHERE id = ? ";
			
			rs = JdbcHelper.query(getExplainerSQL, explain1.getUser().getId());
			if (rs.next()) {
			    User u = new User();
			    // 封装数据
			    u.setId(rs.getInt(1));
			    u.setUsername(rs.getString(2));
			    u.setPassword(rs.getString(3));
			    // 将获取到的用户数据设置到 Topic 对象的 user 属性中
			    explain1.setUser(u);
			    explainList.add(explain1);
			    System.out.println("explain username:" + rs.getString(2));
			}
			JdbcHelper.release(rs); // 关闭结果集
			/*t.setExplains(explains); // 将解答设置到 Topic 对象上
*/		}
		t.setExplains(explainList);
		
		/*** 为 所有的解答,获取解答者的详细信息 ***/
		HttpSession session = request.getSession();
		session.setAttribute("topic", t);
		response.sendRedirect( request.getContextPath() + "/detail.html" );
		return; // 让方法立即结束
	    } catch (NumberFormatException e) {
		e.printStackTrace();

	    } catch (SQLException e) {
		e.printStackTrace();

	    }
	} else {
	}
	response.sendRedirect(request.getContextPath() + "/list.do");

    }

}

解答问题前台显示界面代码;

<!DOCTYPE html>

<html>
	<head>
		<meta charset="UTF-8">
		<title>$topic.title</title>
		<link rel="shortcut icon" href="$path/images/icon.png" type="image/png">
	    <link rel="stylesheet" href="$path/styles/general.css">
	    <link rel="stylesheet" href="$path/styles/cell.css">
	    <link rel="stylesheet" href="$path/styles/wen.css">
	</head>
	<body>
	
		## 登录状态栏 开始
		<div class="login-status-container  auto-height">
				<span class="welcome cell-8">
					## 在 $ 之后 表达式之前使用 ! 表示 安静模式 ( 静默模式 )
					<b>欢迎$!user.username来到问道</b>
				</span>
				<span class="login-operation cell-4">
					#if( $user )
						<a href="$path/ask.html">提问</a>
						<em>|</em>
						<a href="">我的提问</a>
						<em>|</em>
						<a href="$path/logout.do">注销</a>
					#else
						<a href="$path/login.html">登录</a>
						<em>|</em>
						<a href="$path/regist.html">注册</a>
					#end
				</span>
		</div> ## 登录状态栏 结束
		
		## 标志区域
		<div class="brand-container  auto-height">
			<div class="logo cell-2">
				<a href="$path"></a>
			</div>
			<div class="slogan cell-10">
				<div>
				</div>
			</div>
		</div>
		
		<div>
			<h3>$topic.title</h3>
			<div class="line"></div>
			<div>
				$topic.content
			</div>
			<div>
				提问时间: $topic.publishTime / 提问者: $topic.user.username
			</div>
		</div>
		
		<div>
			#foreach( $ex in $topic.explains)
				<div> $ex.content  </div>
				<div class="line"></div>
			#end
		</div>
		
		$scope.remove( $session , 'topic' );
		
		<div class="line"></div>
		
		<div class="container link-container">
		    <a href="$path/ask.html" >发起新问题</a>
		    |
		    <a href="$path/index.html" >返回首页</a>
		</div>
		
		<div class="container copyright-container">
		    &copy; 2017 爱问社区版权所有
		</div>
	
	</body>
</html>

我的解答Servlet处理代码:

@WebServlet("/myAnswer.do")
public class MyAnswerServlet extends HttpServlet {

    private static final long serialVersionUID = -3020889403557912216L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {	    
	    HttpSession session = request.getSession();
	    User user = (User) session.getAttribute( "user" ); // 在登录时将 User 对象放入了 会话 中
	    Explain ex=null;
	    final List<Explain> exp = new ArrayList<>();
	    if( user != null ) {
		int myid=user.getId();
		final String SQL = "SELECT  id ,content ,explain_time , explain_ip , user_id ,topic_id  FROM t_explain WHERE user_id = ? ";
		ResultSet rs = JdbcHelper.query(SQL, myid);
		//Topic t=null;
		//final List<Explain> explains = new ArrayList<>();
		@SuppressWarnings("unused")
		int topicId=-1;
		try {
		    while( rs.next() )
		    {
			ex=new Explain();
			ex.setId(rs.getInt(1));
			ex.setContent(rs.getString(2));
			ex.setExplainTime(rs.getTimestamp( 3 ));
			ex.setExplainIp(rs.getString(4));
			ex.setUser(user);
			Topic to=new Topic();
			to.setId(rs.getInt(6));
			ex.setTopic(to);
			topicId=rs.getInt(6);
			exp.add(ex);
			
		    }
		    JdbcHelper.release(rs); // 关闭结果集
		    
		    for(int i = 0 , len = exp.size() ; i <  len ; i++)
		    {
			Explain explain=exp.get(i);
			Topic tid=explain.getTopic();
			final String tSQL = "SELECT  id , title , content , publish_time , publish_ip , user_id  FROM t_topic WHERE id = ? ";
			ResultSet trs = JdbcHelper.query(tSQL, tid.getId());
			while(trs.next())
			{
			   Topic t=new Topic();
			    t.setId(1);
			    t.setTitle(trs.getString(2));
			    t.setContent(trs.getString(3));
			    t.setPublishTime(trs.getTimestamp(4));
			    t.setPublishIp(trs.getString(5));
			    ex.setTopic(t);
//			    explains.add(ex);
			    System.out.println( "我的tid: " + tid.getId());
			}
			
			JdbcHelper.release(trs); // 关闭结果集
		    }
		    
		    
		} catch (SQLException e) {
		    // TODO Auto-generated catch block
		    e.printStackTrace();
		}
		
		
		session.setAttribute("explains", exp);
		
		System.out.println( "我的解答列表: " + exp );
		System.out.println( "我的id: " + myid);
		response.sendRedirect( request.getContextPath() + "/myAnswer.html");
	    }
	}
     

}

我的解答前台展示页面代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>解答</title>
    <link rel="stylesheet" href="$path/styles/top.css">
    
</head>
<body>
<div style="margin-left:320px;">
<nav id="topnav" class="f_r">
    <ul>
      <a href="$path/index.html"">首页</a> <a href="$path/myQuestion.do" >我的提问</a>
       <a href="$path/ask.html" >提问</a> <a href="$path/logout.do">注销</a>
    </ul>
  </nav>
 </div>
#if( $user )
$user.username的所有回答:
#end
#foreach( $ex in $explains)
<div class="blogs">
<ul>
    <p>$ex.content</p>
    <div class="content_time">
       <p> 解答时间:<span class="dtime f_l"> $ex.explainTime</span></p>
    </div>
    <div class="line"></div>
</ul>
</div>
#end

</body>
</html>

我的提问Servlet处理:

@WebServlet("/myQuestion.do")
public class MyQuestionServlet extends HttpServlet {

    private static final long serialVersionUID = -4110483126223561394L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {	    
	    HttpSession session = request.getSession();
	    User user = (User) session.getAttribute( "user" ); // 在登录时将 User 对象放入了 会话 中
	    if( user != null ) {
		int myid=user.getId();
		final String SQL = "SELECT id , title , content, publish_time , publish_ip FROM t_topic WHERE user_id = ? ";
		ResultSet rs = JdbcHelper.query(SQL, myid);
		final List<Topic> qtopics = new ArrayList<>();
		try {
		    while( rs.next() ){
			Topic t=new Topic();
			t.setId(rs.getInt(1));
			t.setTitle(rs.getString(2));
			t.setContent(rs.getString(3));
			t.setPublishTime(rs.getTimestamp(4));
			t.setPublishIp(rs.getString(5));
			qtopics.add(t);
			
			
		    }
		} catch (SQLException e) {
		    // TODO Auto-generated catch block
		    e.printStackTrace();
		}
		
		
		session.setAttribute("qtopics", qtopics);
		
		System.out.println( "我的提问列表: " + qtopics );
		System.out.println( "我的id: " + myid);
		response.sendRedirect( request.getContextPath() + "/myQuestion.html");
	    }
	}
     

}

我的提问展示代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>$user.username的提问 </title>
     <link rel="stylesheet" href="$path/styles/general.css">
	    <link rel="stylesheet" href="$path/styles/cell.css">
	    <link rel="stylesheet" href="$path/styles/wen.css">
	    <link rel="stylesheet" href="$path/styles/top.css">
</head>
<body>


<div style="margin-left:320px;">
            <ul>
           #if($user)
					<nav id="topnav" class="f_r">
						<ul>
							<a href="$path/index.html">首页</a>
							<a href="$path/myAnswer.do" >我的解答</a>
							<a href="$path/ask.html">提问</a>
							<a href="$path/logout.do" >注销</a>
						</ul>
					</nav>
					#else
                 <li class="presentation"><a href="$path/login.html" id="link" title="提问">登录</a></li>
                <li class="presentation"><a href="$path/regist.do" id="tools" title="exit">注册</a></li>
                #end
            </ul>
</div>
  #if( $user )
                $user.username的所有提问:
                #end
                #foreach( $qto in $qtopics)

<div class="blogs">
        <ul>
        	<p>$qto.content</p>
          <p class="autor"><span class="lm f_l"><a>提问者:$user.username</a></span>  <span class="dtime f_l">$qto.publishTime</span></p>
        </ul>
        
      </div>
      #end

</body>
</html>


验证码处理的Servlet代码:

@WebServlet(urlPatterns= { "/verify/login.do" , "/verify/regist.do" } )
public class VerifyCodeServlet extends HttpServlet {
	
	private static final long serialVersionUID = 3398560501558431737L;

	@Override
	protected void service( HttpServletRequest request , HttpServletResponse response ) 
			throws ServletException, IOException {
		
		// 获得 当前请求 对应的 会话对象
		HttpSession session = request.getSession();
		
		// 从请求中获得 URI ( 统一资源标识符 )
		String uri = request.getRequestURI();
		System.out.println( "hello : " + uri );
		
		final int width = 180 ;  // 图片宽度
		final int height = 40 ; // 图片高度
		final String imgType = "jpeg" ; // 指定图片格式 (不是指MIME类型)
		final OutputStream output = response.getOutputStream(); // 获得可以向客户端返回图片的输出流 (字节流)
		// 创建验证码图片并返回图片上的字符串
		String code = GraphicHelper.create( width, height, imgType, output );
		System.out.println( "验证码内容: " + code );
		
		// 建立 uri 和 相应的 验证码 的关联 ( 存储到当前会话对象的属性中 )
		session.setAttribute( uri , code );
		
		System.out.println( session.getAttribute( uri ) );
		
	}

}

注册前台界面,有验证码验证功能:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>注册爱问社区</title>

    <link rel="stylesheet" href="$path/styles/general.css">
    <link rel="stylesheet" href="$path/styles/cell.css">
    <link rel="stylesheet" href="$path/styles/form.css">

    <link rel="stylesheet" href="$path/awesome/css/font-awesome.min.css">
    
    <script type="text/javascript" src="$path/js/wen.js"></script>

    <style type="text/css" >

        .logo-container {
            margin-top: 50px ;
        }
        .logo-container img {
            width: 100px ;
        }

        .message-container {
            height: 80px ;
        }

        .link-container {
            height: 40px ;
            line-height: 40px ;
        }

        .link-container a {
            text-decoration: none ;
        }

    </style>

</head>
<body>

<div class="container title-container" style="color:blue; margin-top:60px;">加入爱问社区,为您答疑解惑</div>
<div class="container form-container">
    <form action="$path/regist.do" method="post">
        <div class="form"> <!-- 注册表单开始 -->

            <div class="form-row">
                        <span class="cell-1">
                            <i class="fa fa-user"></i>
                        </span>
                        <span class="cell-11" style="text-align: left;">
                            <input type="text" name="username" placeholder="请输入用户名">
                        </span>
            </div>

            <div class="form-row">
                        <span class="cell-1">
                            <i class="fa fa-key"></i>
                        </span>
                        <span class="cell-11" style="text-align: left;">
                            <input type="password" name="password" placeholder="请输入密码">
                        </span>
            </div>

            <div class="form-row">
                        <span class="cell-1">
                            <i class="fa fa-keyboard-o"></i>
                        </span>
                        <span class="cell-11" style="text-align: left;">
                            <input type="password" name="confirm" placeholder="请确认密码">
                        </span>
            </div>
			
            <div class="form-row">
                        <span class="cell-7">
                            <input type="text" name="verifyCode" placeholder="请输入验证码">
                        </span>
                        <span class="cell-5" style="text-align: center;">
                            <img src="$path/verify/regist.do"  οnclick="myRefersh(this)">
                        </span>
            </div>

            <div class="form-row" style="border: none;">
                        <span class="cell-6" style="text-align: left">
                           <input type="reset" value="重置">
                        </span>
                        <span class="cell-6"  style="text-align:right;">
                            <input type="submit" value="注册">
                        </span>
            </div>

        </div> <!-- 注册表单结束 -->
    </form>
</div>
<div class="container message-container">
    <!-- 显示提示信息的地方 -->
    #if( $registFail ) 
   		$registFail
   		$scope.remove( $session , 'registFail' )
    #end
</div>
<div class="container link-container">
    <a href="$path/login.html" > 已注册爱问帐号,点击这里登录</a>
    |
    <a href="$path/index.html" >返回首页</a>
</div>
<div class="container copyright-container">
    &copy; 2017 爱问社区版权所有
</div>

</body>
</html>

Servlet处理注册,实现验证码验证:

@WebServlet("/regist.do")
public class RegistServlet extends HttpServlet {

	private static final long serialVersionUID = 7493633832455111617L;

	@Override
	protected void service( HttpServletRequest request , HttpServletResponse response ) 
			throws ServletException, IOException {
		
		// 获得来自 页面 表单上的数据
		String verifyCode = request.getParameter( "verifyCode" ) ; // 获得由用户输入的那个验证码
		String username = request.getParameter( "username" ) ;
		String password = request.getParameter( "password" ) ;
		String confirm = request.getParameter( "confirm" ) ;
		
		System.out.println( "username : " + username );
		System.out.println( "password : " + password );
		System.out.println( "confirm : " + confirm );
		System.out.println( "verifyCode : " + verifyCode );
		
		HttpSession session = request.getSession();
		// 获得 在 会话 中存储的那个 为登录进行验证的 验证码
		final String code = (String)session.getAttribute( "/wendao/verify/regist.do" );
		System.out.println( "session code : " + code );
		
		// 比较验证码
		if( StringHelper.equals( verifyCode , code ) ){
			// 要保证 用户名 不为空 、密码不能为空 、两次输入的密码必须一致
			if( StringHelper.notEmpty( username ) 
					&& StringHelper.notEmpty( password ) 
					&& StringHelper.equals( password , confirm) ) {
				// 可以保存了 
				String SQL = "INSERT INTO t_user ( username , password ) VALUES ( ? , ? ) " ;
				int n = JdbcHelper.insert( SQL , false , username , StringHelper.MD5(password));
				if( n > 0 ) { // 如果 insert 返回 大于 0 的数字 , 则表示 插入成功
					// 保存成功以后,应该去一个新的页面 ( 比如去 登录页面 )
					response.sendRedirect( request.getContextPath() + "/login.html" );
				} else {
					// 回到注册页面去
					session.setAttribute( "registFail" , "注册失败,可能是用户名被占用了" );
					response.sendRedirect( request.getContextPath() + "/regist.html" );
				}
			} else {
				// 回到注册页面去
				session.setAttribute( "registFail" , "用户名或密码为空,或者密码不一致" );
				response.sendRedirect( request.getContextPath() + "/regist.html" );
			}
		} else {
			// 如果验证码不一致,设置提示信息后回到注册页面去
			session.setAttribute( "registFail" , "验证码输入错误,请重新输入" );
			response.sendRedirect( request.getContextPath() + "/regist.html" );
		}
		
	}
       
}

登录Servlet处理代码:

@WebServlet("/login.do")
public class LoginServlet extends HttpServlet {

	private static final long serialVersionUID = 18854422651747352L;

	@Override
	protected void service( HttpServletRequest request , HttpServletResponse response ) 
			throws ServletException, IOException {
		
		// 获得来自 页面 表单上的数据
		String username = request.getParameter( "username" ) ;
		String password = StringHelper.MD5(request.getParameter( "password" )) ;
		
		System.out.println( "username : " + username );
		System.out.println( "password : " + password );
		
		HttpSession session = request.getSession();
		
			
			// 登录 : 根据 用户名 和 密码 从数据库中查询数据,如果都正确,就将这些数据放入到会话中,最后进入到指定页面( list.html )
			String SQL = "SELECT id , username , password FROM t_user WHERE username = ? and password = ? " ;
			ResultSet rs = JdbcHelper.query( SQL,  username , password ) ;
			
			try{
				// 如果查询到数据,就包装到一个对象中
				if( rs.next() ) {
					User user = new User(); // 创建对象
					
					// 封装数据
					user.setId( rs.getInt( 1 ) );
					user.setUsername( rs.getString( 2 ));
					user.setPassword( rs.getString( 3 ) ) ;
					//System.out.println("测试"+MD5.convertMD5(MD5.convertMD5(password)));
					/** 将 User 对象 放入到 会话中 **/
					session.setAttribute( "user" , user );
					// 重定向到 list.do ( list.do 会先查询数据后 再 重定向到 list.html )
					response.sendRedirect( request.getContextPath() + "/list.do" );
				} else {
					// 如果 用户名 或 密码 错误,重新返回到 登录页面
				    	session.setAttribute( "loginFail" , "用户名或密码错误" );
					response.sendRedirect( request.getContextPath() + "/login.html" );
				}
			} catch ( SQLException e ){
				e.printStackTrace();
			}
	}    
}

登录前台展示界面代码;

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录</title>

    <link rel="stylesheet" href="styles/general.css">
    <link rel="stylesheet" href="styles/cell.css">
    <link rel="stylesheet" href="styles/form.css">

    <link rel="stylesheet" href="awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="css/login.css">
    <script type="text/javascript" src="js/wen.js"></script>

</head>
<body>
	<div class="logina-logo" style="height: 55px">
            <div id="venusLogo"><p><span>爱问社区</span></p></div>
        </div>
        <div class="logina-main main clearfix">
            <div class="tab-con">
                <form action="$path/login.do" method="post">
                    <div id='login-error' class="error-tip"></div>
                    <table border="0" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <th>账户</th>
                                <td width="245">
                                    <input type="text" name="username" id="username" placeholder="昵称" /> 
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <th>密码</th>
                                <td width="245">
                                    <input type="password" name="password" id="password" placeholder="密码" />
                                </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
         						<th></th>
                                <td width="245"><input class="confirm" type="submit" value="登  录"></td>
                                <td></td>
                            </tr>
                        </tbody>
                    </table>
                </form>
            </div>
            <div class="reg">
                <p>还没有账号?<br>赶快免费注册一个吧!</p>
                <a class="reg-btn" href="regist.html">立即免费注册</a>
            </div>
        </div>
        <div id="footer">
            <div class="copyright">Copyright © 爱问社区 版权所有</div>
        </div>   
</body>
</html>

好啦,基本的代码就展示完了,还有比较通用的POJO类和jdbc连接数据库的类就不做展示了,贴上数据库SQL代码,需要的可以根据字段来写

DROP TABLE IF EXISTS `t_explain`;
CREATE TABLE `t_explain` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `content` text,
  `explain_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `explain_ip` varchar(50) DEFAULT NULL,
  `user_id` int(8) DEFAULT NULL,
  `topic_id` int(8) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ex_id` (`user_id`),
  KEY `t_id` (`topic_id`),
  CONSTRAINT `ex_id` FOREIGN KEY (`user_id`) REFERENCES `t_user` (`id`),
  CONSTRAINT `t_id` FOREIGN KEY (`topic_id`) REFERENCES `t_topic` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for t_topic
-- ----------------------------
DROP TABLE IF EXISTS `t_topic`;
CREATE TABLE `t_topic` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) DEFAULT NULL,
  `content` text,
  `publish_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `publish_ip` varchar(100) DEFAULT NULL,
  `user_id` int(10) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `cid` (`user_id`),
  CONSTRAINT `cid` FOREIGN KEY (`user_id`) REFERENCES `t_user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for t_user
-- ----------------------------
DROP TABLE IF EXISTS `t_user`;
CREATE TABLE `t_user` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `username` varchar(20) NOT NULL,
  `password` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;

源码工程地址:https://github.com/guodalin8/wendao      哪里有问题欢迎留言,看到第一时间解答。


基于百度理解与交互技术实现机器问答

一、前言我们都知道现在聊天对话机器是一个很有意思的东西,比如说苹果siri,比如说微软的小冰。聊天对话机器的应用场景也很广泛,比如说:银行的自助办卡机器人、展会讲解解说等等。 我们对机器人说句话,机器人... 查看详情

问答系统介绍

...#160;   (2)生成式3.依据答案来源分类:(1)基于知识图谱问答系统(2)机器阅读理解的问答系统(3)基于问答对的问答系统    定义:给定自然语言处理问题,通过对问题进行语义理解和解析,进而... 查看详情

论文笔记基于知识图谱的农业智能问答系统

基于知识图谱的农业智能问答系统前言知识图谱简介知识图谱生命周期知识获取知识抽取知识存储与应用相关技术和工具农业知识图谱构建流程本体层构建实体层构建基于Neo4j的农业知识图谱问答系统算法设计基于知识图谱的问... 查看详情

基于javawebjsp+servlet学生宿舍管理系统设计和实现

本项目演示链接地址》主要技术:spring、jsp、servlet、mysql、tomcat 、jsp、jquery、css、c390、cookie、session等基本技术实现主要功能:不同角色登录、宿舍管理员管理、学生信息管理、宿舍信息管理、学生缺勤管理、修改密码和退出... 查看详情

servlet基础(代码片段)

...期,为替代笨拙的CGI技术,Sun公司在制定JavaEE规范时引入Servlet,实现了基础Java语言的动态Web技术,奠定了JavaEE的基础,使动态Web开发技术达到了一个新的境界。如今,Servlet在普遍使用的MVC模式的Web开发中仍占据了重要地位,目... 查看详情

基于servlet3.0+ibatis+bootstrip技术构建简单会议管理系统

网盘地址:https://pan.baidu.com/s/1i65cPSD密码:63ia网盘地址:https://pan.baidu.com/s/1kXmqkM7密码:v4ry本系统是应用于企业会议管理的系统,实现自动管理会议室,及时准确得知会议室空闲、预定情况,规范公司会议管理,实现公司信息资源... 查看详情

基于知识图谱的电影推荐问答系统实战

基于知识图谱的电影推荐问答系统实战知识图谱电影推荐系统Demo环境数据集文件结构运行过程声明数据集介绍数据集预处理导入数据库连接数据库驱动清空数据库创建电影实体创建用户实体与评分关系创建电影类型实体加载关... 查看详情

超级简单的javaweb适合初学者学习基于servlet客户关系管理系统设计与实现(源码)

...理的添加、删除、修改基本操作(CRUD)系统采用servlet框架结构2、项目技术后台架构:servlet前台技术:Bootstrap+jQUery+Ajax+CSS+HTML3、开发环境系统环境:Windows10JDK版本:JDK1.8服务器:Tomcat9.0开... 查看详情

javaweb基于servlet天气预报查询系统设计与实现(项目源码)

采用技术:servlet前后端数据的传输采用json方式数据源采用定义的文件json格式获取讲所有格式编码转化为UTF-8线上访问地址:http://localhost:8080/weather/json数据格式化的转化采用谷歌组件gson读取所有省份访问接口文件province.x... 查看详情

基于移动端的问答系统--需求分析与原型设计

...否将自己锻造成特色鲜明的应用型人才尤为重要,而这款基于移动端的问答系统可 查看详情

公司内部传递的java技术问答集锦

1说出Servlet的生命周期,并说出Servlet和CGI的区别Servlet被服务器实例化后,容器运行其init方法,请求到达时运行其service方法,service方法自动派遣运行与请求对应的doXXX方法(doGet,doPost)等,当服务器决定将实例销毁的时候调用... 查看详情

servlet概述

1什么是servlet?Servlet是基于Java技术的web组件,容器托管的,用于生成动态内容。像其他基于Java的组件技术一样,Servlet也是基于平台无关的Java类格式,被编译为平台无关的字节码,可以被基于Java技术的webserver动态加载并运行。... 查看详情

大数据知识图谱项目——基于知识图谱的医疗知识问答系统(详细讲解及源码)(代码片段)

基于知识图谱的医疗知识问答系统一、项目概述本项目基于医疗方面知识的问答,通过搭建一个医疗领域知识图谱,并以该知识图谱完成自动问答与分析服务。本项目以neo4j作为存储,基于传统规则的方式完成了知识... 查看详情

大数据知识图谱项目——基于知识图谱的医疗知识问答系统(详细讲解及源码)(代码片段)

基于知识图谱的医疗知识问答系统一、项目概述本项目基于医疗方面知识的问答,通过搭建一个医疗领域知识图谱,并以该知识图谱完成自动问答与分析服务。本项目以neo4j作为存储,基于传统规则的方式完成了知识... 查看详情

编一套程序基于jsp+javabean+servlet的学生管理系统怎么做?

参考技术A1、先想想你要实现的功能有哪些,也就是概要设计2、再根据概要设计,进行分析和讨论,定稿3、设计数据库,搭建开发环境及系统框架。4、开始前台jsp后台servlet的开发。5、测试,部署。本回答被提问者和网友采纳 查看详情

基于jsp实现oa办公系统

项目编号:BS-XX-039后台技术:JSP+Servlet+JDBC前端技术:Ajax+Jquery数据库:Mysql5.7应用服务器:Tomcat8.5.31开发工具:IDEA/Eclipse项目说明:本项目基于JavaWeb技术开发实现了一套完整的OA办公系统࿰ 查看详情

基于java+jsp+servlet的养老院管理系统设计和实现《收藏版》(代码片段)

java毕业设计项目《100套》推荐一、  选题的依据及意义随着信息化技术的发展,敬老院的信息化管理也迎来了机遇和挑战,我们积极应对这场战斗,丝毫不懈怠。因为,在未来的互联网是一个开放的环境,而... 查看详情

基于ssm+jsp实现的民宿预订网站(用户管理房源管理注册登录民宿预定订单管理订单删除等)

基于SSM+JSP实现的民宿预订网站(用户管理、房源管理、注册登录、民宿预定、订单管理、订单删除等)@目录基于SSM+JSP实现的民宿预订网站实现功能截图系统功能使用技术完整源码基于SSM+JSP实现的民宿预订网站本系统是SSM的民... 查看详情