struts2入门 struts str

学习struts2需要什么基础

如果想学好struts2,我个人建议你需要看看servlet,jsp,拦截器,国际化,还有一些标签啊。因为这些都和struts2相关联很紧的,像你所列举的javascript,EL表达式,ajax这些都是前端技术,如果要做项目,这些也都是必不可少的,因为你都是要拿到和显示数据的!

Struts2框架里的Struts.xml配置文件里的拦截器和Action各自什么意思,二者有什么关系,初学,求高手指点~

拦截器拦截请求(Request),阻止非法请求,比如字符乱码,登录,权限。Action就是业务处理请求的中心,所有请求在这里被处理里,处理结果又Action返回一个逻辑视图。这张图最典型了。

编写一个简单的Struts2入门实例

首先,struts2进行权限验证是用拦截器做的
一个简单的登录拦截器示例如下:
package com.zdf.interceptor;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.zdf.entity.Admin;
@SuppressWarnings(“serial“)
public class LoginInterceptor extends AbstractInterceptor{
@Override
public String intercept(ActionInvocation invocation) throws Exception {
// TODO Auto-generated method stub
Admin admin = (Admin)invocation.getInvocationContext().getSession().get(“ADMIN“);
if(admin!=null){
return invocation.invoke();
}else{
return Action.LOGIN;
}
}

}

struts2入门老提示The requested resource is not available.

访问路径
http://localhost:8080/yourAppName/login
应该打开 welcome.jsp
报错不能打开,需要设置struts.xml,去掉action 的 class,试试

struts2的入门问题、、

什么都不写 就是从 ValueStack里取值 写 #变量名 是在 ActionContext中取变量值 #request.变量名 #session.变量名 #application.变量名
在制定作用域中获取变量值

java eestruts2初学,这第一个几乎么都没干的程序为什么这样也可以访问到index.jsp页面

http://localhost/struts2_001_HelloWorld/这个url访问时在web.xml里面配置的
《welcome-file-list》
《welcome-file》index.jsp《/welcome-file》
《/welcome-file-list》