Я пытался запустить приложение с плагином соглашения Struts2. Приложение было хорошо с struts.xml
настроен так:плагин struts2 conventions не работает должным образом
<struts>
<package name="struts2demo" extends="struts-default">
<action name="hey" class="action.CountryAction" method="get">
<result name="success">/index.jsp</result>
</action>
<action name="add" class="action.CountryAction" method="add">
<result type="redirect" name="success">hey</result>
</action>
<!-- Add your actions here -->
</package>
</struts>
Теперь я удалил, что struts.xml
и добавлены некоторые аннотации, как это:
@Namespace("/")
@ResultPath(value="/")
public class CountryAction extends ActionSupport implements ModelDriven<Country>{
private List<Country> worldCountry;
private Country country = new Country();
public Country getCountry() {
return country;
}
public void setCountry(Country country) {
this.country = country;
}
// HttpServletRequest request;
@Action(value="/hey",results={@Result(name="success",location="/index.jsp")})
public String get() throws SQLException
{
CountryService cs = new CountryService();
setWorldCountry(cs.getCountry());
// System.out.println(getWorldCountry());
return SUCCESS;
}
public List<Country> getWorldCountry() {
return worldCountry;
}
public void setWorldCountry(List<Country> worldCountry) {
this.worldCountry = worldCountry;
}
@Override
public Country getModel() {
return country;
}
}
, но когда я пытаюсь запустить приложение я получаю следующее ошибка:
сообщений:
There is no Action mapped for namespace [/] and action name [hey] associated with context path [/JustStruts2].
Мои web.xml
это:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>struts.devMode</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Где я делаю неправильно, любая помощь будет оценена.
С уважением.
asm-commons.jar для решения этой проблемы – Aadam