用struts2写一个helloworld
来源:互联网 发布:网络自制节目有哪些 编辑:程序博客网 时间:2024/06/06 08:23
本文原创,转载请注明出处。。
首先,配置web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name></display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>其次,将包导入到lib里面
之后,再导入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><constant name="struts.devMode" value="true" /><package name="default" namespace="/" extends="struts-default"> <action name="hello"><result>/Hello.jsp</result></action></package></struts>再建好hello.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%><%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>helloStruts</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 World! <br> </body></html>这样,就成功了:
0 0
- 用struts2写一个helloworld
- 用java写一个HelloWorld
- 让我们用Backbone.js来写一个HelloWorld程序。
- 用PhoneGap在Android平台下写一个HelloWorld
- MAC下用MyEclipse写一个servlet的helloworld
- 在linux下用C写一个HelloWorld(GCC版)
- 用smali写一个java加法程序和HelloWorld程序
- 用txt写HelloWorld
- 用C++写HelloWorld
- 自己动手写一个Struts2
- 自己动手写一个Struts2
- struts2的一个helloWorld小例子
- 在inet下写一个“HelloWorld”程序
- android studio写一个helloworld项目
- (三)自己写一个HelloWorld类
- struts2 一个简单的 struts2程序(HelloWorld)
- 用GTK+写的HelloWorld
- Struts2 ------ HelloWorld
- 新闻系统——VS制作自己的模板
- CC3D 代码的研究
- 使用virtualbox安装VBoxGuestAdditions增强工具 共享文件夹失败问题
- linux 信号处理机制
- LOD地形
- 用struts2写一个helloworld
- M3800的故事——电源4
- POJ 3468 【线段树】
- c/c++基本类型所占字节数
- 远程方法调用(RMI)
- Visualbox 共享文件夹的问题
- uml类图
- 用python搭建简单的聊天程序
- 网站改版样例