1. Trang chủ
  2. » Thể loại khác

prepare interceptor trong struts 2

2 131 1

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

http://vietjack.com/struts_2/index.jsp Copyright © vietjack.com prepare Interceptor Struts prepare Interceptor gọi phương thức prepare() action triển khai Preparable Interface Nó gọi phương thức prepare() trước gọi phương thức execute() Để sử dụng prepare Interceptor, bạn cần triển khai Preparable Interface lớp action bạn ghi đè phương thức prepare Theo mặc định, tìm thấy default stack, bạn khơng cần xác định cách tường minh prepare Interceptor định nghĩa tham số, là: alwaysInvokePrepare: theo mặc định, thiết lập true Ví dụ prepare Interceptor Struts login-success.jsp Lớp Action Lớp Action phải triển khai Prepare Interface ghi đè phương thức prepare() package com.vietjack; import com.opensymphony.xwork2.Preparable; public class LoginAction implements Preparable{ private String name,password; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { http://vietjack.com/ Trang chia sẻ học online miễn phí Page http://vietjack.com/struts_2/index.jsp Copyright © vietjack.com return password; } public void setPassword(String password) { this.password = password; } public void prepare() throws Exception { System.out.println("Trinh prepare logi"); } public String execute(){ System.out.println("Trinh logic thuc su"); return "success"; } } http://vietjack.com/ Trang chia sẻ học online miễn phí Page ...http://vietjack.com /struts_ 2/ index.jsp Copyright © vietjack.com return password; } public void setPassword(String password) { this.password = password; } public void prepare( ) throws Exception... this.password = password; } public void prepare( ) throws Exception { System.out.println("Trinh prepare logi"); } public String execute(){ System.out.println("Trinh logic thuc su"); return "success";

Ngày đăng: 02/12/2017, 21:01

Xem thêm:

TỪ KHÓA LIÊN QUAN

Mục lục

    prepare Interceptor trong Struts 2

    Ví dụ prepare Interceptor trong Struts 2

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN