我一直在尝试将 Tiles 与基于 Struts 2 注释的操作集成,但它无法正常工作。
由于我没有,struts-config.xml
并且在网络上可用的每个教程中,他们都使用struts-config.xml
.
首先,是否可以将基于注释的 struts 动作与瓦片集成。如果是,那怎么办?
@Action(value="/login",results={@Result(name="success",location="/home",type=TilesResult.class),
@Result(name="login",location="/jsp/userLogin.jsp")})
public String execute() {
这就是我的代码,但它总是在 MyEclipse 中给我TilesResult.class
错误
Type mismatch: cannot convert from Class<TilesResult> to String
我的 pom 中有依赖项:
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
<version>2.1.8</version>
</dependency>
谁能帮助我如何在基于注释的操作中添加图块
我使用type="tiles"
而不是type=TilesResult.class
then 它给了我以下异常
Caused by: The Result type [tiles] which is defined in the Result annotation on the class [class com.actions.LoginAction] or determined by the file extension or is the default result type for the PackageConfig of the action, could not be found as a result-type defined for the Struts/XWork package [com.actions#convention-default#] - [unknown location]
at org.apache.struts2.convention.DefaultResultMapBuilder.createResultConfig(DefaultResultMapBuilder.java:422)
at org.apache.struts2.convention.DefaultResultMapBuilder.createFromAnnotations(DefaultResultMapBuilder.java:394)
at org.apache.struts2.convention.DefaultResultMapBuilder.build(DefaultResultMapBuilder.java:202)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.createActionConfig(PackageBasedActionConfigBuilder.java:800)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.java:586)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:318)
at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)