这几天看了看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>
这里面基本空空,
action文件
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 {
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
System.out.println("hello this is execute method!");
return SUCCESS;
}
@Action("showthis")
public String mymethod() throws Exception{
System.out.println("-----------------------------------");
return SUCCESS;
}
}
这里面定义了两个方法,然后我再web——info这个目录下,新建了一个jsp文件夹,再里面新建了一个hello.jsp和一个showthis.jsp
之后再浏览器输入http://localhost:8088/test/hello.action,则调用execute方法,然后返回到hello.jsp页面;输入http://localhost:8088/test/showthis.action,则调用mymethod() ,页面跳转到showthis.jsp页面。
注意:一定要导入struts2-convertion-plugs这个jar包,我用的struts2的jar包是2.1版本的
分享到:
相关推荐
struts2.1.6 convertion插件(即注释方式配置)的helloworld 默认调用index()方法 文档说明用struts.xml中标签设置值,好象不用也行 rest插件例子 默认调用 create()方法 struts2.1.6 vistor校验例子 都是我测试例子,...
这种方式主要是利用了com.opensymphony.xwork2.ActionContext类以及org.apache.struts2.ServletActionContext类,具体的方法如下所示。 获得request对象: A . HttpServletRequest request = ServletActionContext....
本程序将'风机信息.txt'中的风机位置(西安1980/北京1954坐标系)转换为经纬度坐标系。 风机参考经纬度.txt'存储了部分的风机的经纬度信息,可以用作转换的基准。
2)....Important: File layout was changed for BDS 2006+. Delphi and C++ Builder files are now located in StudioNum folders instead of old DelphiNum and CBuilderNum folders. Update your search paths if ...
外转换 出xml转换htmltoxml
Convertion program from Matlab to C++ using Armadillo
地心惯性坐标系到地理坐标系;地理坐标系到地球坐标系等转换,共计8个程序
温度传感器温度与阻值快速转换工具,支持pt1000,pt100,ntc20k,ntc10k
Z-Y'-X'' euler angles' definition, convertion to rotation matrix, and relationship with angular velocity. (source:http://personal.maths.surrey.ac.uk/T.Bridges/SLOSH/3-2-1-Eulerangles.pdf)
'Dateteim convertion class,All functions are shared. Public Shared Function GetMonthList(Optional ByVal MonthCount As Int16 = 5) As String() If MonthCount = 0 Then MonthCount = 1 End If Dim ...
Keras-OpenFace是一个将从其原始Torch实现转换为版本的项目 如果您只对使用预先训练的模型感兴趣 加载Keras OpenFace模型(精度:0.938 + -0.013) from keras . models import load_model from keras . utils ...
针对部分GIMMS 3G V1原始数据下载后格式为hdf,不适用于nc4格式。nc4格式请下载GIMMS 3g v1 convert
整个程序的功能是将华氏温度转化为摄氏温度
UL508C标准 UL Standard for Safety for Power Conversion Equipment Third Edition, Dated May 3, 2002
该程序可用于GIMMS 3g v0/v1 数据转换
c++调用约定 c++的集中约定分析 各种约定之间的区别及其用法
datasets and OnTag event.Data tables in report.Conditional blocks in report template.Custom SQL Queries in report template.Excel pivot tables in report.Direct dataset to XLS file convertion (no MS ...
Wordlist manipulation; Raptor is known to security experts for its outstanding features ... The macro [lower][pass] resulted in an uppercase convertion of the password instead of a lowercase convertion.
svg2vector:SVG图像到Android矢量可绘制XML资源文件的在线批处理转换器
基于msp430F5438A的4通道8次AD转换程序,可参考调用