Struts2 HelloWorld实现
来源:互联网 发布:互联网数据分析师前景 编辑:程序博客网 时间:2024/05/22 03:04
1、创建javaweb项目 并且导入需要的包(此处用的是Struts2.3)
2、创建web.xml配置文件 并且完成配置
<?xml version="1.0" encoding="UTF-8"?><web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>Struts Blank</display-name> <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> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>
3、创建cn.xm.action包并且在其中创建HelloAction类
package cn.xm.action;import com.opensymphony.xwork2.ActionSupport;public class HelloAction extends ActionSupport{ @Override public String execute() throws Exception { // TODO Auto-generated method stub return SUCCESS; }}
4、在src下创建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.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="true" /> <package name="default" namespace="/" extends="struts-default"> <action name="Hello" class="cn.xm.action.HelloAction"> <result name = "success">show.jsp</result> </action> </package></struts>
4、在WebContent下创建show.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Insert title here</title></head><body>HelloWorld!</body></html>
5、在tomcat上启动该项目 在url中输入地址得到HelloWorld!
阅读全文
0 0
- 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-helloworld
- struts2-helloworld
- Struts2实现通过浏览器返回一个helloworld页面给用户
- Struts2(一)-Struts2之HelloWorld
- Struts2的HelloWorld程序
- Struts2.0.1HelloWorld
- ubuntu系统的定制裁剪(适用于嵌入式瘦客户端)
- Android横竖屏切换咱得知道的一些东西
- 机房错误解决与知识总结-1
- lesson7
- 一、Android安全机制之前言
- Struts2 HelloWorld实现
- java语言程序设计 第十三章 抽象类与接口 (13.2、13.3、13.4)
- ActiveMQ(2)-一些配置
- CS50 2017 Lecture 0
- 苏嵌学习的第一天
- 2018网易校招内推--彩色砖块
- Recyclerview布局多条目加载+上下拉
- 属性动画模版
- MVP登录注册