struts2+convertion实现struts.xml的零配置
这几天看了看struts2,有看了一些教程,发现零配置这个思想挺好的,可以简化好多代码!于是就学着做了起来。
struts.xml配置文件
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"><struts><constant name="struts.convention.result.path" value="/WEB-INF/jsp/"/><!-- 将跳转路径指向/WEB-INF/jsp文件夹下 --></struts>
package com.song.action;import org.apache.struts2.convention.annotation.Action;import org.apache.struts2.convention.annotation.Namespace;import com.opensymphony.xwork2.ActionSupport;public class Hello extends ActionSupport {@Overridepublic String execute() throws Exception {// TODO Auto-generated method stubSystem.out.println("hello this is execute method!");return SUCCESS;}@Action("showthis")public String mymethod() throws Exception{System.out.println("-----------------------------------");return SUCCESS;}}