首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

struts-简介(一)

2012-08-27 
struts--简介(1)Struts2为无侵入式,提供拦截器,表现层的支持struts 对指定方法检验package nameitcas

struts--简介(1)

Struts2为无侵入式,提供拦截器,表现层的支持

<struts> 对指定方法检验

  <package name="itcast“ namespace="/control/employee" extends="struts-default"

   <action name="list" class="cn.itcast.action.HelloWorld.action method="excute">

       <result name="success" type="redirect>/employee.jsp?username=${username}</result>

  <aciton>

  <action name="redirect">

     <result  type="redirect">/employeeAdd.jsp</result>

  <aciton>

  <action name="redirectAction">

    <result  type="redirectAction">list</result>

  <aciton>

<package>

<struts>

搭建struts2的开发环境:1、找到开发Struts2应用所需要的jar文件 2、编写struts配置文件 3、在web.xml重加入struts2 MVC框架的启动配置

最少jar文件:struts-core.jar xwor.jar  ognl.jar  freemark.jar  commons-logging.jar  commons-file-upload.jar

在web.xml文件中加入filter:StrutsPrepareAndExccuteFlter的init()方法读取类路径下的struts.xml文件 

将读取的struts.xml数据以javabean的形式存入内存中,以后可以重复使用

 

一定要继承struts-defautl包

通过E-R表达式可以访问Action里面的属性 ${username}

一定要有get方法 并且为getXxx() 如:getMessage()

在jsp页面或者html页面敲击标签时没有提示是因为没有找到dtd文件,如果联网可以解决这个问题,有的时候是工具的原因、一般是很少出现的

没有联网的解决办法:window---myeclipse--xml---xml catalog---add---文件系统---选择struts.dtd相关的dtd文件--url--把struts2.x里面的http://struts.apache.org/dtds/struts-2.0dtd(放入key中)---ok--回车保存

热点排行