struts2.x把jsp页面放入web-inf保护起来的访问方式

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
  
  <title>My JSP 'index.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>
  This is my JSP page. <br>
<s:url id="url" action="main"></s:url>
<s:a href="%{#url}">link </s:a>
</body>
</html>

struts.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="aaa" extends="struts-default">
  <action name="main" class="aaa.IndexAction">
  <result name="success">/WEB-INF/jsp/main.jsp</result>
  </action>
</package>
</struts>

IndexAction:
package aaa;

import com.opensymphony.xwork2.ActionSupport;

public class IndexAction extends ActionSupport{

public String execute() throws Exception
{
return "success";
}
}

你可能感兴趣的:(java,apache,jsp,Web,struts)