vi du url validation trong struts 2

4 143 0
vi du url validation trong struts 2

Đ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 url Validation Struts url Validator kiểm tra xem giá trị cung cấp có chuỗi url hợp lệ không Chỉ có tham số định nghĩa cho url Validator, là:  fieldName: xác định tên trường mà để validate Nó bắt buộc Plain-Validator Ví dụ url validation Cho Plain Validator: website Website URL khong hop le Cho Field Validator: Website URL khong hop le Ví dụ đầy đủ url validation Struts Tạo index.jsp Cho input từ người dùng Nó nhận name, password, email id từ người dùng http://vietjack.com/ Trang chia sẻ học online miễn phí Page http://vietjack.com/struts_2/index.jsp Copyright © vietjack.com errorMessage{color:red;} Tạo lớp action : Lớp kế thừa lớp ActionSupport ghi đè phương thức validate RegisterAction.java package com.vietjack; import com.opensymphony.xwork2.ActionSupport; public class Register extends ActionSupport{ private String url; public String getUrl() { return url; } public void setUrl(String url) { http://vietjack.com/ Trang chia sẻ học online miễn phí Page http://vietjack.com/struts_2/index.jsp Copyright © vietjack.com this.url = url; } public String execute(){ return "success"; } } Tạo validation file Tại sử dụng bundled validator để thực trình validation Register-validation.xml URL khong duoc de trong URL phai chinh xac, vi du http://www.vietjack.com http://vietjack.com/ Trang chia sẻ học online miễn phí Page http://vietjack.com/struts_2/index.jsp Copyright © vietjack.com Tạo struts.xml xml file định nghĩa result tên nhập, interceptor jsonValidatorWorkflowStack index.jsp welcome.jsp Tạo thành phần view JSP file đơn giản hiển thị thông tin người dùng welcome.jsp URL is: http://vietjack.com/ Trang chia sẻ học online miễn phí Page ... http://vietjack.com/ Trang chia sẻ học online miễn phí Page http://vietjack.com /struts_ 2/ index.jsp Copyright © vietjack.com this .url = url; } public String execute(){ return "success"; } } Tạo validation. .. Foundation//DTD Struts Configuration 2. 1//EN" "http:/ /struts. apache.org/dtds /struts- 2. 1.dtd"> ... "http://www.opensymphony.com/xwork/xwork-validator-1.0 .2. dtd"> URL khong duoc de trong< /message> URL phai

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

Từ khóa liên quan

Mục lục

  • url Validation trong Struts 2

    • Ví dụ url validation

    • Ví dụ đầy đủ url validation trong Struts 2

      • Tạo index.jsp

      • Tạo lớp action

      • Tạo validation file

      • Tạo struts.xml

      • Tạo các thành phần view

Tài liệu cùng người dùng

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

Tài liệu liên quan