Struts2 当我尝试从另一个页面注销时,没有在主页上获取样式?

Struts2 当我尝试从另一个页面注销时,没有在主页上获取样式?,struts2,Struts2,我开发了一个简单的struts2 web应用程序。 其中有两个页面index.jsp和page1.jsp,它们位于名为Page 我使用了以下jar文件 antlr.jar commons-beanutils.jar commons-digester.jar commons-fileupload.jar commons-logging.jar commons-logging-1.0.4.jar commons-validator.jar freemarker-2.3.8.jar

我开发了一个简单的struts2 web应用程序。 其中有两个页面index.jsppage1.jsp,它们位于名为Page

我使用了以下jar文件

 antlr.jar
 commons-beanutils.jar
 commons-digester.jar
 commons-fileupload.jar
 commons-logging.jar
 commons-logging-1.0.4.jar
 commons-validator.jar
 freemarker-2.3.8.jar
 jakarta-oro.jar
 jsf-api.jar
 jsf-impl.jar
 jstl-1.2.jar
 ognl-2.6.11.jar
 struts.jar
 struts2-core-2.0.11.2.jar
 xwork-2.0.5.jar
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>
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
   <package name="helloworld" extends="struts-default">

      <action name="log1" class="com.loginAction">
            <result name="success">/index.jsp</result>
      </action>
   </package>
</struts>
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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_Sample</display-name>

   <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
         org.apache.struts2.dispatcher.FilterDispatcher
      </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>
loginAction.java

package com;
import com.opensymphony.xwork2.ActionSupport;
public class loginAction extends ActionSupport {

    public String execute() {
         return SUCCESS;        
    }
}
下图显示了我的应用程序的目录结构。

当我运行该应用程序时,它将指向index.jsp页面,其中会出现一个登录超链接。这个页面有一个橄榄色的背景色,我在style.css中定义了这个颜色。现在,当我单击它时,它将指向page1.jsp,显示两个文本字段和一个提交按钮

问题:

当我单击submit按钮时,它将指向上一个index.jsp,但没有任何背景色。即使单击该按钮,也会显示一个错误页面。

以下图片附件显示了我的应用程序的所有网页。

当我点击登录超链接时,我会看到错误页面

有人能告诉我为什么我会这样。

这个问题有什么解决办法。
代替
css/style.css
。它首先使用
index.jsp
,因为jsp正在搜索同一目录中的css文件夹,但是当您访问其他两个页面时,它正在搜索页面文件夹中的css文件夹

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
<body>
<s:form action="log1" method="post">
  <s:textfield name="name" label="USERNAME"></s:textfield>
   <s:password name="pass" label="PASSWORD"></s:password>
  <s:submit method="execute" label="LOGIN"></s:submit>
</s:form>
</body>
</html>
body 
{
background:olive;
}
package com;
import com.opensymphony.xwork2.ActionSupport;
public class loginAction extends ActionSupport {

    public String execute() {
         return SUCCESS;        
    }
}