1. 主要文件 LoginAction.java
package com.edu.struts2.action;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import com.opensymphony.xwork2.ActionSupport;
@Namespace("/struts2_annotaction")
public class LoginAction extends ActionSupport {
}
2. 主要文件2 login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!-- 访问的路径的action名字是类名除了Action之外的名字,首字母不大写。如:类LoginAction访问的action路径为login.action -->
</html>
3. 工程的struts2的jar包使用编译器自动导入的。主要是这个jar:struts2-convention-plugin-2.3.4.1.jar
4。 整个流程比起xml配置简单了很多,思路也更容易理解了。并且之前的struts.xml可以删除了!!!可以不用这个配置文件也能实现基本的功能了。。
5. 更多的信息可以看这里:
http://struts.apache.org/release/2.1.x/docs/convention-plugin.html#ConventionPlugin-Actionannotation
6. 你也可以直接访问struts2的官网获取最新的消息。