《Struts 系列》- 入门例子
2018-01-18 00:00
281 查看
项目结构
build.gradle
struts.xml
struts.properties
HelloAction.java
测试
http://localhost:8989/struts-helloworld/hello
http://localhost:8989/struts-helloworld/hello.action
build.gradle
apply plugin:'war' apply plugin:'eclipse-wtp' sourceCompatibility = 1.7 repositories{ maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' } } dependencies{ compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0' compile group: 'javax.servlet', name: 'jstl', version: '1.2' compile group: 'javax.servlet.jsp', name: 'javax.servlet.jsp-api', version: '2.2.1' compile group: 'org.apache.struts', name: 'struts2-core', version: '2.3.24' }
struts.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <!-- name="hello":对应请求的地址,注意没有后缀 class:为该名称,指定一个动作类 method:对应hello要执行的方法 --> <package name="hellodemo" extends="struts-default" namespace="/"> <action name="hello" class="com.kimisme.action.HelloAction" method="sayHello"> <result name="success">/views/success.jsp</result> </action> </package> </struts>
struts.properties
# 设置为开发模式 struts.devMode=true
HelloAction.java
public class HelloAction { /** * 动作方法书写要求: * 1.public * 2.返回值String类型 * 3.没有任何参数 * @return */ public String sayHello(){ return "success"; } }
测试
http://localhost:8989/struts-helloworld/hello
http://localhost:8989/struts-helloworld/hello.action
相关文章推荐
- opengl入门系列- openglES 2.0 的 VBO 用法和例子
- Struts tiles入门(最最简单的例子)
- Struts入门的一个例子
- SSH系列(一)struts入门
- C# 串口操作系列(1) -- 入门篇,一个标准的,简陋的串口例子。
- wxWidgets系列之入门例子
- C# 串口操作系列(1) -- 入门篇,一个标准的,简陋的串口例子。
- Struts tiles入门(最最简单的例子)
- C# 串口操作系列(1) -- 入门篇,一个标准的,简陋的串口例子
- Struts 入门例子
- [Struts 2系列] Struts 2入门之HelloWorld
- C# 串口操作系列(1) -- 入门篇,一个标准的,简陋的串口例子。
- 【转载】CANoe 入门 Step by step系列(三)简单例子的剖析
- struts+hibernate+spring入门例子
- C# 串口操作系列(1) -- 入门篇,一个标准的,简陋的串口例子。
- SpringMVC笔记系列(1)——用一个例子帮你入门
- C# 串口操作系列(1) -- 入门篇,一个标准的,简陋的串口例子
- OpenGL入门系列6 - 累积缓冲区用法例子
- Struts2.0 入门系列文章 —— 转载 —— 很好很强大 !
- C# 串口操作系列(1) -- 入门篇,一个标准的,简陋的串口例子