0

有没有人尝试部署 struts2-jquery-showcase-3.6.0.war 。? 我从下载战争文件

http://code.google.com/p/struts2-jquery/downloads/list

并将其导入 Eclipse 并从源 jar 的同一链接中获取源。

目前,应用程序已启动并运行良好,但

当我浏览应用程序时,我发现了一个观察结果:

项目结构

在此处输入图像描述

web.xml

  <?xml version="1.0" encoding="UTF-8"?>
<web-app id="struts2-jquery-showcase" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <display-name>Struts jQuery Plugin - Showcase</display-name>

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</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>

索引.jsp

<% response.sendRedirect("index.action"); %>

ShowCase.java

    /*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package com.jgeppert.struts2.jquery.showcase;

import java.util.HashMap;
import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;

public class ShowCase extends ActionSupport {

    private static final long serialVersionUID = -7133848243722723891L;
    private String theme = "showcase";
    private boolean google = false;
    private boolean ajaxhistory = false;
    private Map<String, String> themes;

    @Action(value = "/index", results = { @Result(location = "index.jsp", name = "success") })

    public String execute() throws Exception {

        System.out.println("in showcase action.......");

        themes = new HashMap<String, String>();

    themes.put("cupertino", "The cupertino Theme");
    themes.put("ui-darkness", "The darkness Theme");
    themes.put("ui-lightness", "The lightness Theme");
    themes.put("redmond", "The redmond Theme");
    themes.put("smoothness", "The smoothness Theme");
    themes.put("black-tie", "The black-tie Theme");
    themes.put("blitzer", "The blitzer Theme");
    themes.put("dark-hive", "The dark-hive Theme");
    themes.put("dot-luv", "The dot-luv Theme");
    themes.put("eggplant", "The eggplant Theme");
    themes.put("excite-bike", "The excite-bike Theme");
    themes.put("flick", "The flick Theme");
    themes.put("hot-sneaks", "The hot-sneaks Theme");
    themes.put("humanity", "The humanity Theme");
    themes.put("le-frog", "The le-frog Theme");
    themes.put("mint-choc", "The mint-choc Theme");
    themes.put("overcast", "The overcast Theme");
    themes.put("pepper-grinder", "The pepper-grinder Theme");
    themes.put("south-street", "The south-street Theme");
    themes.put("start", "The start Theme");
    themes.put("sunny", "The sunny Theme");
    themes.put("swanky-purse", "The swanky-purse Theme");
    themes.put("trontastic", "The trontastic Theme");
    themes.put("vader", "The vader Theme");

    themes.put("showcase", "The custom Showcase Theme");

    return SUCCESS;
    }

    public String getTheme() {
    return theme;
    }

    public void setTheme(String theme) {
    this.theme = theme;
    }

    public Map<String, String> getThemes() {
    return themes;
    }

    public boolean isGoogle() {
    return google;
    }

    public void setGoogle(boolean google) {
    this.google = google;
    }

    public boolean isAjaxhistory() {
    return ajaxhistory;
    }

    public void setAjaxhistory(boolean ajaxhistory) {
    this.ajaxhistory = ajaxhistory;
    }
}

struts.xml

    <?xml version="1.0" encoding="UTF-8" ?>
<!--
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
-->

<!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.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="true" />
    <constant name="struts.convention.action.packages" value="com.jgeppert.struts2.jquery.showcase"/>
    <constant name="struts.convention.default.parent.package" value="json-default"/>
    <constant name="struts.custom.i18n.resources" value="messages" />


    <!-- Settings for CKEditor Image Upload -->
    <constant name="struts.ckeditor.allowUploads" value="true" /> <!-- default is false -->
    <constant name="struts.ckeditor.allowedFileExtensions" value="jpg,jpeg,png" />
    <constant name="sstruts.ckeditor.uploadFolder" value="/imageUploads" />

    <!-- include file="showcase.xml" / -->
</struts>

现在,当结果“成功”呈现时,它会重定向到文件夹“内容”中名为“index.jsp”的页面,即层次结构路径“WEB-INF/content/index.jsp”

我的问题是 ,当结果的位置属性中没有提到它时,它如何被重定向到内容文件夹内的页面?

当我让项目在调试模式下运行时,我开始了解 content/index.jsp。我搜索了整个项目,但找不到“内容”的痕迹..

4

1 回答 1

1

WAR 项目包含struts2-convention-plugin-2.3.14.2.jar插件

这个插件可以让你通过使用convention. 为此,JSP 页面必须放在WEB-INF/文件夹中。

这就是struts.xml 和showcase.xml 没有定义动作映射的原因。

有关更多信息,请参见http://struts.apache.org/release/2.3.x/docs/convention-plugin.html

你可以阅读:

By default, the Convention plugin assumes that all of the results are stored in WEB-INF/content. This can be changed by setting the property struts.convention.result.path in the Struts properties file to the new location.

于 2013-07-05T06:14:49.800 回答