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.configuration.xml.reload" value="true"/>
<!--
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" /> <package name="default" namespace="/" extends="struts-default"> <default-action-ref name="index" /> <global-results>
<result name="error">/error.jsp</result>
</global-results> <global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings> <action name="index">
<result type="redirectAction">
<param name="actionName">HelloWorld</param>
<param name="namespace">/example</param>
</result>
</action>
</package>
<include file="example.xml"/>
--> <!-- Add packages here --> <package name="default" namespace="/" extends="struts-default">
<action name="hello">
<result>/Hello.jsp</result>
</action>
</package> </struts>

namespace 为 "/",action 的 name 为 hello,访问路径就是:http://localhost:8080/Struts2_0100_Introduction/hello.action (.action 可以不要)

Hello.jsp

 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello Struts2</title>
</head>
<body>
<h1>Hello Struts2</h1>
</body>
</html>

部署后即可访问。

代码链接:http://pan.baidu.com/s/1miAy27I 提取码:fhhk

Struts2_HelloWorld_3的更多相关文章

随机推荐

  1. javascript的offset、client、scroll、screen使用方法

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAHuCAYAAABpm/53AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjw

  2. Kibana6.x.x——启动后警告信息:Session cookies will be transmitted over insecure connections. This is not recommended.

    启动Kibana后,如果你看到如下警告信息: server log [08:03:18.001] [warning][security] Session cookies will be transmi ...

  3. poj1062 昂贵的礼物(dijkstra+枚举)

    传送门:点击打开链接 题目大意:买东西,每个东西有了替代品,拥有替代品后可以有优惠价格,每个物品的主人有自己的等级,等级超过m的不能直接或者间接交易,问买1号物品的最低价格是多少. 思路:一开始想到d ...

  4. 321B

    MCMF必须是满足流量最大为前提下的最小费用流(这里是最大费用流) 因此还必须不断地枚举m的流量才行 #include<iostream> #include<algorithm> ...

  5. 找到一篇关于 Oracle 全文检索实践 的文章

    http://www.iteye.com/topic/1118055 有详细的例子记录了Oracle 全文检索的使用.

  6. hdu1387 模拟队列

    Team Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  7. 基于ksoap2-android的soap的封装

    实例基于ksoap2-android-assembly-3.3.0-jar-with-dependencies.jar 1:定义回调接口,通过泛型确定返回值类型 package com.ciii.bd ...

  8. CHUCK手把手带你搞定OPENSTACK

    一.OpenStack初探 1.1 OpenStack简介 OpenStack是一整套开源软件项目的综合,它允许企业或服务提供者建立.运行自己的云计算和存储设施.Rackspace与NASA是最初重要 ...

  9. vmware 三种连接方式 如何设置独立ip

    转载:https://blog.csdn.net/xiaoyangsavvy/article/details/73718473

  10. vue(6)生态

    来自:https://www.jianshu.com/p/22a99426b524?utm_campaign=maleskine&utm_content=note&utm_medium ...