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