1

IntelliJ 環境で struts 2 とタイルの統合を開始しました。

Web でいくつかのチュートリアルを検索しましたが、奇妙なシンボルが見つからないという問題がまだ見られます。

これは web.xml です。

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
     version="2.5">

<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>

<context-param>
    <param-name>tilesDefinitions</param-name>
    <param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<listener>
    <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
</web-app>

これは tiles.xml です

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE tiles-definitions PUBLIC
   "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
   "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">

<tiles-definitions>

  <definition name="baseLayout" template="/baseLayout.jsp">
      <put-attribute name="title"  value="Template"/>
      <put-attribute name="header" value="/header.jsp"/>
      <put-attribute name="menu"   value="/menu.jsp"/>
      <put-attribute name="body"   value="/body.jsp"/>
      <put-attribute name="footer"   value="/footer.jsp"/>
  </definition>

  <definition name="welcome" extends="baseLayout">
      <put-attribute name="title"  value="Welcome"/>
      <put-attribute name="body"   value="/welcome.jsp"/>
  </definition>

  <definition name="friends" extends="baseLayout">
      <put-attribute name="title"  value="Friends"/>
      <put-attribute name="body"   value="/friends.jsp"/>
  </definition>

  <definition name="office" extends="baseLayout">
      <put-attribute name="title"  value="Office"/>
      <put-attribute name="body"   value="/office.jsp"/>
  </definition>

</tiles-definitions>

WEB-INF ディレクトリの下のタイルと web.xml の両方。

これは、src ディレクトリの下の 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="FirstWebApp" extends="struts-default">
        <result-types> <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/> </result-types> 
        <action name="*Link" method="{1}" class="hello.HelloWorld">

            <result type="tiles" name="welcome">welcome</result>
            <result type="tiles" name="friends">friends</result>
            <result type="tiles" name="office">office</result>
        </action>
    </package>
</struts>

4 つのエラーが発生しています。以下の 2 つの異なるグループに属していると思います。

  1. エラー:(12, 13) シンボル「ようこそ」を解決できません
  2. エラー:(13, 13) シンボル「友達」を解決できません
  3. エラー:(8, 42) パッケージ 'struts-default' を解決できません
  4. エラー:(14, 13) シンボル 'office' を解決できません

エラー 3 については、インターネットから struts-default.xml を追加すると、com.opensymphony.xwork2 パッケージに関連する他のクラスが見つからないというエラーが多数表示されました。

エラー 1、2、4 については、struts.xml に tiles.xml を見てシンボルを解決する方法がわかりません。

助けてくれてありがとう。

4

1 に答える 1

1

name = "welcome" name = "friends" name = "office"を削除し、「struts-default」の代わりに「tiles-default」を使用します

于 2010-03-10T10:32:12.440 に答える