struts2学习笔记1
HelloWorld实例(快速上手)
struts2.1.8
新建一个web项目,
按照目录结构 添加struts.xml&所用到的jar
struts.xml(配置各请求要执行的action)
默认执行execute方法。使用method=””指定执行的方法?
?
?
?
<?xml version="1.0" encoding="GBK" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"><struts><package name="struts2_HelloWorld_001" extends="struts-default"><action name="HelloWorld" name="code"><%@ page language="java" pageEncoding="ISO-8859-1"%><%@ taglib uri="/struts-tags" prefix="s" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html"></head><body><s:property value="message"/></body></html>
?
package com.suning.demo;import com.opensymphony.xwork2.ActionSupport;public class HelloWorld extends ActionSupport {private String message;public String getMessage() {return message;}public void setMessage(String message) {this.message = message;}public String execute() {this.message = "Hello World yangying";return SUCCESS;}}
??
?
URL:http://localhost:8080/struts2_001_HelloWorld/HelloWorld?????????????????????????????????????? (HelloWorld在Struts.xml中指定action name)?
?
代码没有贴出来,放到 :https://struts2-001.googlecode.com/svn/trunk/
是鄙人第一篇博文,请大家多多谅解。
?