@Namespace(value = "msgAction")
@Action(value = "msg", results = { ... })
public class MsgAction extends ActionSupport {
public String getInfo() { ... }
}
訪問 https://localhost:8080/AppServer_1.1/msgAction/msg.do 無反應、無報錯、不進方法。
@Namespace("msgAction") 對應 URL 路徑 /msgAction/;@Action("msg") 對應 msg(含 .do 後綴由 struts.action.extension 定義);/msgAction/msg.do** —— **與用戶 URL 一致**;struts.xml 中 <package name="msg"> 未包含註解掃描包路徑,且註解掃描需 struts.convention.action.packages 或 struts.convention.package.locators 配置;@Controller + @Scope("prototype"),且 Struts2 需 struts.objectFactory=spring。struts.xml 添加約定插件配置:<constant name="struts.convention.action.packages" value="com.AppServer.action" />
<constant name="struts.convention.package.locators" value="action" />
struts2-convention-plugin JAR 在 classpath 中;@ParentPackage("convention-default") 繼承約定包;web.xml Filter 映射 /* 是否攔截 .do;struts.devMode=true 查看詳細日志。