我已经启用了Struts2约定插件。
package system;
@Namespace("/customer")
public class IndexAction extends ActionSupport {
public execute() {
return SUCCESS;
}
}如果我输入http://localhost:8080/customer/和http://localhost:8080/customer/index.action,两个都可以到达同一个页面。
如何禁用http://localhost:8080/customer/而只允许使用http://localhost:8080/customer/index.action访问?
发布于 2020-10-16 23:31:45
当调用http://localhost:8080/customer时,Struts2将找到映射到相应名称空间的操作(即IndexAction),并重定向到execute() (默认)方法。
如果您不想要此行为,可以删除execute()并在类中创建特定方法
public String index() {
return SUCCESS;
}对应的URL是http://localhost:8080/customer!index (http://localhost:8080/customer!index.action也可以)
https://stackoverflow.com/questions/64316744
复制相似问题