日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

软件工程概论课后作业01

發(fā)布時(shí)間:2023/12/10 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 软件工程概论课后作业01 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1. 網(wǎng)站系統(tǒng)開發(fā)需要掌握的技術(shù)

①java語言

Java語言體系比較龐大,包括多個(gè)模塊。從WEB項(xiàng)目應(yīng)用角度講有JSP,Servlet,JDBC,JavaBean(Application)四部分技術(shù)。JDBC可做三件事情:與數(shù)據(jù)庫建立連接,發(fā)送SQL語句,處理結(jié)果。Servlet從客戶端(通過WEB服務(wù)器)接受請求,執(zhí)行某種操作,然后返回結(jié)果。JSP是從Servlet上分離出來的一小部分,簡化了開發(fā),加強(qiáng)了頁面設(shè)計(jì)。JavaBean能提供常用功能并且可以重復(fù)使用,這使得開發(fā)人員可以把某些關(guān)鍵功能和核心算法提取出來封裝成為一個(gè)組件對象,這樣就增加了代碼的重用率和系統(tǒng)的安全性。

②面向?qū)ο蠓治鲈O(shè)計(jì)思想

Java語言是完全面向?qū)ο蟮恼Z言,所以在項(xiàng)目設(shè)計(jì)時(shí)會(huì)有很大的幫助,在設(shè)計(jì)時(shí)應(yīng)盡量舍棄以往的面向過程的設(shè)計(jì)方式。

③設(shè)計(jì)模式和構(gòu)架結(jié)構(gòu)

設(shè)計(jì)模式在java項(xiàng)目實(shí)施過程更是重中之重。主要在與兩層的設(shè)計(jì)模式,三層的設(shè)計(jì)模式和N層的設(shè)計(jì)模式。它直接決定著項(xiàng)目的應(yīng)用,部署和實(shí)際開發(fā)設(shè)計(jì)。

④XML語言

在服務(wù)器和設(shè)計(jì)模式結(jié)構(gòu)中會(huì)應(yīng)用到自定義文件,而且在應(yīng)用高級設(shè)計(jì)時(shí)也會(huì)定義自用的標(biāo)簽,現(xiàn)在流行的是用XML去定義配置,所以XML語言應(yīng)該有一定掌握。XML大致可以分為3類,分別是簡單數(shù)據(jù)的表示和交換,面向消息的計(jì)算,用戶界面相關(guān)。

⑤網(wǎng)頁腳本語言

網(wǎng)頁腳本語言的執(zhí)行都是在客戶端執(zhí)行的,速度很快,并且大多數(shù)的操作與服務(wù)器沒有交互計(jì)算,所以在一些應(yīng)用中非常理想。在設(shè)計(jì)WEB項(xiàng)目的應(yīng)用中,網(wǎng)頁的腳本語言起著不能忽視的作用,對JAVAScript應(yīng)有一定的了解。

⑥開發(fā)工具

數(shù)據(jù)庫,Web服務(wù)器,集成開發(fā)環(huán)境

2.源代碼

package com.jaovo.msg.dao; import java.util.List; import com.jaovo.msg.model.User; public interface IUserDao {public void add(User user);public void delete(int id);public void update(User user);public User load(int id);public User load(String username);public List<User> load(); } package com.jaovo.msg.dao;import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List;import com.jaovo.msg.Util.DBUtil; import com.jaovo.msg.Util.UserException; import com.jaovo.msg.model.User;import sun.net.www.content.text.plain;public class UserDaoImpl implements IUserDao {@Overridepublic void add(User user) {//獲得鏈接對象Connection connection = DBUtil.getConnection();//準(zhǔn)備sql語句String sql = "select count(*) from t_user where username = ?";//創(chuàng)建語句傳輸對象PreparedStatement preparedStatement = null;ResultSet resultSet = null;try {preparedStatement = connection.prepareStatement(sql);preparedStatement.setString(1, user.getUsername());//接收結(jié)果集resultSet = preparedStatement.executeQuery();//遍歷結(jié)果集while(resultSet.next()) {if (resultSet.getInt(1) > 0) {throw new UserException("用戶已存在") ;}}sql = "insert into t_user(username,password,nickname) value (?,?,?)";preparedStatement = connection.prepareStatement(sql);preparedStatement.setString(1, user.getUsername());preparedStatement.setString(2, user.getPassword());preparedStatement.setString(3, user.getNickname());preparedStatement.executeUpdate();} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();}finally {//關(guān)閉資源 DBUtil.close(resultSet);DBUtil.close(preparedStatement);DBUtil.close(connection);}}@Overridepublic void delete(int id) {Connection connection = DBUtil.getConnection();String sql = "delete from t_user where id = ?";PreparedStatement preparedStatement = null;try {preparedStatement = connection.prepareStatement(sql);preparedStatement.setInt(1, id);preparedStatement.executeUpdate();} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();}finally {DBUtil.close(preparedStatement);DBUtil.close(connection);}}@Overridepublic void update(User user) {Connection connection = DBUtil.getConnection();//準(zhǔn)備sql語句String sql = "update t_user set password = ? , nickname=? where id = ?";//創(chuàng)建語句傳輸對象PreparedStatement preparedStatement = null;try {preparedStatement = connection.prepareStatement(sql);preparedStatement.setString(1, user.getPassword());preparedStatement.setString(2, user.getNickname());preparedStatement.setInt(3, user.getId());preparedStatement.executeUpdate();} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();}finally {DBUtil.close(preparedStatement);DBUtil.close(connection);}}@Overridepublic User load(int id) {Connection connection = DBUtil.getConnection();//準(zhǔn)備sql語句String sql = "select * from t_user where id = ?";//創(chuàng)建語句傳輸對象PreparedStatement preparedStatement = null;ResultSet resultSet = null;User user = null;try {preparedStatement = connection.prepareStatement(sql);preparedStatement.setInt(1, id);resultSet = preparedStatement.executeQuery();while(resultSet.next()) {user = new User();user.setId(id);user.setUsername(resultSet.getString("username"));user.setPassword(resultSet.getString("password"));user.setNickname(resultSet.getString("nickname"));}} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();}finally {DBUtil.close(resultSet);DBUtil.close(preparedStatement);DBUtil.close(connection);}return user;}@Overridepublic User load(String username) {// TODO Auto-generated method stubreturn null;}@Overridepublic List<User> load() {Connection connection = DBUtil.getConnection();//準(zhǔn)備sql語句String sql = "select * from t_user ";//創(chuàng)建語句傳輸對象PreparedStatement preparedStatement = null;ResultSet resultSet = null;//集合中只能放入user對象List<User> users = new ArrayList<User>();User user = null;try {preparedStatement = connection.prepareStatement(sql);resultSet = preparedStatement.executeQuery();while(resultSet.next()) {user = new User();user.setId(resultSet.getInt("id"));user.setUsername(resultSet.getString("username"));user.setPassword(resultSet.getString("password"));user.setNickname(resultSet.getString("nickname"));users.add(user);}} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();}finally {DBUtil.close(resultSet);DBUtil.close(preparedStatement);DBUtil.close(connection);}return users;}} package com.jaovo.msg.model;public class User {private int id;private String username;private String nickname;private String password;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getNickname() {return nickname;}public void setNickname(String nickname) {this.nickname = nickname;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}} package com.jaovo.msg.Util;import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException;public class DBUtil {public static Connection getConnection() {try {//1 加載驅(qū)動(dòng)Class.forName("com.mysql.jdbc.Driver").newInstance();} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {// TODO Auto-generated catch block e.printStackTrace();}String user = "root";String password = "root";String url = "jdbc:mysql://localhost:3306/jaovo_msg";Connection connection = null;try {//2 創(chuàng)建鏈接對象connectionconnection = DriverManager.getConnection(url,user,password);} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();}return connection;}//關(guān)閉資源的方法public static void close(Connection connection ) {try {if (connection != null) {connection.close();}} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();}}public static void close(PreparedStatement preparedStatement ) {try {if (preparedStatement != null) {preparedStatement.close();}} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();}}public static void close(ResultSet resultSet ) {try {if (resultSet != null) {resultSet.close();}} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();}}} package com.jaovo.msg.Util;public class UserException extends RuntimeException{public UserException() {super();// TODO Auto-generated constructor stub }public UserException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {super(message, cause, enableSuppression, writableStackTrace);// TODO Auto-generated constructor stub }public UserException(String message, Throwable cause) {super(message, cause);// TODO Auto-generated constructor stub }public UserException(String message) {super(message);// TODO Auto-generated constructor stub }public UserException(Throwable cause) {super(cause);// TODO Auto-generated constructor stub }} <%@page import="com.jaovo.msg.Util.UserException"%> <%@page import="com.jaovo.msg.dao.UserDaoImpl"%> <%@page import="com.jaovo.msg.model.User"%> <%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <%//接收客戶端傳遞過來的參數(shù)String username = request.getParameter("username");String password = request.getParameter("password");String nickname = request.getParameter("nickname");if(username == null || "".equals(username.trim())){request.setAttribute("error", "用戶名不能為空");%><jsp:forward page="addInput.jsp"></jsp:forward> <%}User user = new User();user.setUsername(username);user.setPassword(password);user.setNickname(nickname);UserDaoImpl userDao = new UserDaoImpl();try{userDao.add(user);//重定向response.sendRedirect("list.jsp"); %><%}catch(UserException e){ %><h2 style="color:red ; font-size:50px">發(fā)生錯(cuò)誤 : <%=e.getMessage() %></h2><%}%> </html> <%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head><title>用戶添加頁面</title> </head> <body><%=request.getAttribute("error") %><form action="add.jsp" method="get"><table align="center" border="1" width="500"><tr><td>用戶名稱 : </td><td><input type="text" name="username" /></td></tr><tr><td>用戶密碼:</td><td><input type="password" name="password" /></td></tr><tr><td>用戶昵稱:</td><td><input type="text" name="nickname" /></td></tr><tr align="center"><td colspan="2"><input type="submit" value="提交" /><input type="reset" value="重置" /></td></tr></table></form> </body> </html>

3.運(yùn)行結(jié)果截圖

?

?4.列出你對這門課的希望和自己的目標(biāo),并具體列出你計(jì)劃計(jì)劃每周花多長時(shí)間在這門課上。

?可以自己開發(fā)系統(tǒng),創(chuàng)建登錄界面。

計(jì)劃除了能夠在規(guī)定時(shí)間內(nèi)完成作業(yè),課下也應(yīng)該要花費(fèi)很多時(shí)間多用于編程上面。計(jì)劃每周花費(fèi)28個(gè)多小時(shí)用于編程。

轉(zhuǎn)載于:https://www.cnblogs.com/lijing925/p/7876039.html

總結(jié)

以上是生活随笔為你收集整理的软件工程概论课后作业01的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。