OGNL(对象图导航语言)基础了解

OGNL(对象图导航语言)基础了解_第1张图片OGNL(对象图导航语言)基础了解_第2张图片OGNL(对象图导航语言)基础了解_第3张图片OGNL(对象图导航语言)基础了解_第4张图片OGNL(对象图导航语言)基础了解_第5张图片OGNL(对象图导航语言)基础了解_第6张图片OGNL(对象图导航语言)基础了解_第7张图片OGNL(对象图导航语言)基础了解_第8张图片

代码如下:Book.java:

package bean;

public class Book {

	private String name;
	private int price;
	private int bookid;

	public int getBookid() {
		return bookid;
	}

	public void setBookid(int bookid) {
		this.bookid = bookid;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public Book(String name, int price, int bookid) {
		super();
		this.name = name;
		this.price = price;
		this.bookid = bookid;
	}

}
ChaoAction.java:
package chao;

import java.util.ArrayList;
import java.util.List;

import bean.Book;

public class ChaoAction {
	private String name;
	private List books;

	public List getBooks() {
		return books;
	}

	public void setBooks(List books) {
		this.books = books;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String execute() {
		books=new ArrayList();
		books.add(new Book("javaweb1",34,1));
		books.add(new Book("javaweb2",322,2));
		books.add(new Book("javaweb3",67,3));
		name = "chao";
		return "list";
	}
}
struts.xml:




	
		
			/WEB-INF/page/message.jsp
		
	

message.jsp:
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>




Insert title here


	
	${name }
	
=======================================

index.jsp:
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
	request.setAttribute("user", "chao");
	request.getSession().setAttribute("user", "chao1");
%>




Insert title here


         <!-- 获得简单属性 -->
	
	



=======================================


你可能感兴趣的:(struts2)