struts2——HelloWorld
来源:互联网 发布:linux系统主要用途 编辑:程序博客网 时间:2024/06/01 14:56
1.strutx.xml的配置
<span style="font-size:18px;"><?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> <!-- Add packages here --> <constant name="struts.devMode" value="true" /><package name="default" namespace="/" extends="struts-default"> <action name="hello"> <result> /jsp/Hello.jsp </result> </action> </package></struts></span>
2.hello.jsp
<span style="font-size:18px;"><%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><%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>HelloStruts2</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> Hello Struts2 <br> </body></html></span>说明:
(1)struts.xml中package中的name的作用就是区别不同的包
(2)namespace是命名空间,也就是需要访问时候需要输入的地址中的一些信息,比如这个就需要输入:http://localhost:8080/项目名/hello.action
(3)<constant name="struts.devMode" value="true" />的意思就是(2)中的后面那个action可以随便写,不影响程序的运行结果
(4)<result></result>是用来返回action所对应的结果页面的。
0 0
- struts2——HelloWorld
- struts2入门—输出helloworld
- struts2基本知识点—HelloWorld篇
- 2011级 csdn-java 王少飞 Struts2——HelloWorld
- struts2笔记(1)——搭建一个HelloWorld
- Struts2 ------ HelloWorld
- Struts2 helloWorld
- struts2 HelloWorld
- struts2 HelloWorld
- struts2 helloworld
- Struts2,HelloWorld
- struts2 helloworld
- Struts2 HelloWorld
- Struts2 HelloWorld!
- struts2-helloworld
- struts2-helloworld
- struts2下的helloworld(如何让第一个struts2跑起来)——struts2第一讲
- Struts2(一)-Struts2之HelloWorld
- vijos P1320 清点人数 题解
- 今天在做HDU1495的时候看到了一个代码
- 【Android开发新手的学习笔记】使用LruCache对ListView进行优化
- Oracle经典教程(推荐)
- OpenCL入门
- struts2——HelloWorld
- TableView2
- Android Scroller完全解析,关于Scroller你所需知道的一切
- MongoDB
- JsViews Error:Unknown template:“#projectData”
- eclipse中JS文件乱码
- LeetCode204. Count Primes
- storyboard解析
- POJ 3166 Treats for the Cows