简单的struts创建
来源:互联网 发布:slf4j 输出sql 编辑:程序博客网 时间:2024/05/17 20:14
(1)点击MyEclipse菜单栏File按钮,点击new-->Web Project
(2)项目创建完成——然后右键项目——点击MyEclipse-->Add Struts Capabilities ...-->选中2.1
(3)点击finish,多出下边的sturs.xml
(3)创建action包下边的类,名为 HelloAction
package action;
public class HelloAction {
public String execute() throws Exception{
System.out.println("执行Action");
return "success";
}
}
(4)在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>
<package name="default" extends="struts-default">
<action name="helloworld" class="action.HelloAction">
<result name="success">/result.jsp</result>
</action>
</package>
</struts>
(5)在创建result.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'result.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This is my result.jsp page. <br>
</body>
</html>
(6)创建index.jsp,通过点击调用sturts
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>文件上传</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This is my JSP page. <br>
<a href="helloworld.action">点击按钮</a>
</body>
</html>
(7)发布项目,点击链接,成功跳转。
- 简单的struts创建
- 创建简单的struts项目
- 手工创建Struts项目的简单例子
- Struts 2.5.2 创建一个简单的项目--登录
- 简单的struts实例
- 最简单的Struts
- Struts的简单使用
- Struts的简单使用
- struts的简单介绍
- struts的简单实现
- Struts的简单应用
- Struts 的简单理解
- Struts入门---最简单的Struts代码
- Struts动态表单的创建
- struts action的动态创建
- Struts工程的创建步骤
- S1.1_Struts2_Model2 手动创建一个简单的servlet项目,未使用Struts技术
- 一个简单的Struts例子
- BZOJ 1036 树的统计Count [树链剖分(点权)]【数据结构】
- 阿里巴巴Java开发手册编程规约
- 杭电2015题
- 如何使用WebLogic发布Web项目
- 先锋机器人学习笔记_1-7 ArRobot类
- 简单的struts创建
- http状态码
- char on arm
- Android又一重磅利器—Lottie安卓开源动画库介绍和使用
- 编程英语中英文对照
- 如何安装WebLogic
- ssm框架的搭建流程
- bootstrap学习笔记
- 继承中的对象模型