Đang chuẩn bị liên kết để tải về tài liệu:
Mastering Jakarta Struts phần 7

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

và các thành phần có thể được thúc đẩy để xây dựng Xem.Như chúng ta đã thảo luận trong Chương 1, "Giới thiệu Jakarta Struts dự án và các thành phần hỗ trợ của nó," Xem Struts được đại diện bởi một sự kết hợp của JSP, các thư viện thẻ tùy chỉnh, và các đối tượng ActionForm tùy chọn. | Building the Employees Application import org.apache.struts.action.ActionMapping import org.apache.struts.action.ActionErrors import org.apache.struts.action.ActionError import javax.sql.DataSource import java.sql.Connection import java.sql.Statement import java.sql.ResultSet import java.sql.SQLException public class AddEmployeeAction extends Action protected void insertUser ActionForm form throws Exception String user null Connection conn null Statement stmt null ResultSet rs null ServletContext context servlet.getServletContext DataSource dataSource DataSource context.getAttribute Action.DATA_SOURCE_KEY try EmployeeForm eForm EmployeeForm form conn dataSource.getConnection stmt conn.createStatement StringBuffer sqlString new StringBuffer insert into employees sqlString.append values eForm.getUsername sqlString.append eForm.getPassword sqlString.append eForm.getRoleid sqlString.append eForm.getName sqlString.append eForm.getPhone sqlString.append eForm.getEmail sqlString.append eForm.getDepid stmt.execute sqlString.toString finally if rs null rs.close if stmt null stmt.close if conn null 156 Building the Employees Application conn.close public ActionForward execute ActionMapping mapping ActionForm form HttpServletRequest request HttpServletResponse response throws IOException ServletException Default target to success String target success EmployeesActionMapping employeesMapping EmployeesActionMapping mapping Does this action require the user to login if employeesMapping.isLoginRequired HttpSession session request.getSession if session.getAttribute USER null The user is not logged in target login ActionErrors errors new ActionErrors errors.add ActionErrors.GLOBAL_ERROR new ActionError errors.login.required Report any errors we have discovered back to the original form if errors.empty saveErrors request errors return mapping.findForward target if isCancelled request Cancel pressed back to employee list return mapping.findForward success try insertUser form catch .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.