Struts2_HelloWorld_3
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的更多相关文章
随机推荐
- git 本地分支与远程分支相关操作记录
1.远程分支中有新增分支,但自己的本地分支没有对应同步 git checkout -b [remote-branch-name] origin/[remote-branch-name] 2. 查看本地 ...
- ubuntu14.04 apt-get install找不到软件,更换源解决
安装14.04后,有时使用apt-get命令安装程序,会提示找不到程序,这是因为软件源不正确,网上说的换163的.中科大的.阿里的等等,我在更新源的时候都会出错,一般是报404错误,网上也没找到好的办 ...
- POJ1057 FILE MAPPING
题目来源:http://poj.org/problem?id=1057 题目大意:计算机的用户通常希望能够看到计算机存储的文件的层次结构的图形化表示.Microsoft Windows的 " ...
- [转]Groovy One Liners to Impress Your Friends
Link:http://arturoherrero.com/2011/06/04/10-groovy-one-liners-to-impress-your-friends/ I find that c ...
- phpsotrm 设置命名空间
PHPStorm 添加支持 PSR-4 命名空间前缀设置 许久没有更新博客啦, 太忙了, 七月这最后一天来写点自己在使用 PHPStorm 上的小却很有用的功能吧. PHPStorm 默认是使用 PS ...
- java Response 设置中文编码
response.setHeader("Content-type", "text/html;charset=UTF-8"); response.setChara ...
- elasticsearch 相关命令
ubuntu server 启动命令:$ ./bin/elasticsearch 后台运行:$ ./bin/elasticsearch -d 查看当前进程:$ jps 启动后检查是否成功命令:$ cu ...
- 读经典——《CLR via C#》(Jeffrey Richter著) 笔记_8.1实例构造器和类A
public class SomeType { } //等价于 public class SomeType { public SomeType():base(){} } [解释]如果定义的类没有显示定 ...
- datatables通过ajax调用渲染数据,怎么根据数据给td添加class
html: <table id="table8" cellpadding="0" cellspacing="0" border=&qu ...
- JS函数调用分析过程