package com.sdlc.action;

 public class HelloWorldAction {

     private String msg;

     public void setMessage(String message) {
this.msg = message;
} public String getMessage() {
return msg;
} public String execute()
{
this.msg="电子商务";
//执行该方法之后返回至名为success的视图
return "success";
} public static void main(String[] args) { } }

HelloWorldAction.java

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Struts2</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>

web.xml

 <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"> <struts>
<package name="sdlc" namespace="/test" extends="struts-default">
<action name="helloworld" class="com.sdlc.action.HelloWorldAction" method="execute" >
<result name="success">/WEB-INF/page/hello.jsp</result>
</action>
</package>
</struts>

struts.xml

 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
${message}
</body>
</html>

hello.jsp

最新文章

  1. (五)WebGIS中通过行列号来换算出多种瓦片的URL 之在线地图
  2. 一周试用yii开发一个带各种该有功能的web程序(二)
  3. eclipse 配置黑色主题
  4. eclispse 中集成多个tomcat
  5. Media Queries详细
  6. OpenGL列主元矩阵的运算
  7. linux printk函数学习
  8. PHP代码,拒绝频繁访问
  9. 分享一个MD5加密工具类
  10. HTML下直接调用Less文件
  11. U盘做svn版本控制
  12. struts2语法--error页面如何捕获?
  13. drupal 8 之 captcha模块
  14. 剑指offer——python【第60题】把二叉树打印成多行
  15. Kotlin 继承
  16. Google的Flutter工具允许开发者开发跨平台应用
  17. POJ - 3122 Pie(二分)
  18. ecmall 如何新增挂件
  19. NHibernate with ASP.NET MVC 入门示例
  20. 前端- html -总结

热门文章

  1. 酷狗、QQ、天天动听——手机音乐播放器竞品对比
  2. PowerShell 中使用json对象的性能比较
  3. Qt编程之对QGraphicsItem点击右键弹出菜单
  4. leetcode: sortlist之四种方法
  5. js深入研究之初始化验证
  6. 【 Failed to create the Java Virtual Machine】的2种解决方式
  7. MVC4.0系统开发新手历程(二)
  8. libeXosip2(2-3) -- eXosip2 event API
  9. 今天弄了整整一天DCloud
  10. C/C++基础概念