通配符设置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通配符设置相关的知识,希望对你有一定的参考价值。

使用通配符,可以将配置量降到最低,不过,一定得遵守“约定优于配置”的原则

package com.bjsxt.struts2.user.action;

import com.opensymphony.xwork2.ActionSupport;

public class StudentAction extends ActionSupport {
public String add() {
return SUCCESS;
}
public String delete() {
return SUCCESS;
}

}


package com.bjsxt.struts2.user.action;

import com.opensymphony.xwork2.ActionSupport;

public class TeacherAction extends ActionSupport {
public String add() {
return SUCCESS;
}

public String delete() {
return SUCCESS;
}


}

 

<?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>
<constant name="struts.devMode" value="true" />
<package name="actions" extends="struts-default" namespace="/actions">
<action name="Student*" class="com.bjsxt.struts2.action.StudentAction" method="{1}">
<result>/Student{1}_success.jsp</result>
</action>

<action name="*_*" class="com.bjsxt.struts2.action.{1}Action" method="{2}">
<result>/{1}_{2}_success.jsp</result>
<!-- {0}_success.jsp -->
</action>
</package>
</struts>

 

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP ‘Studentadd_success.jsp‘ starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
Student Add Success!

</body>
</html>

 

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP ‘Studentadd_success.jsp‘ starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
Teacher Add Success!

</body>
</html>

大家一起改进与交流

以上是关于通配符设置的主要内容,如果未能解决你的问题,请参考以下文章

struts----通配符设置

在本地主机(OS X 10.5)上设置通配符域?

课时81.通配符选择器(理解)

在 apache 2.2.3 上设置通配符子域(带有反向代理)

在通配符 vhost apache (xampp) 设置中重定向子子域

通配符虚拟主机 Ubuntu