首页 > 其他 > 详细

struct2(一)第一个struct程序

时间:2014-09-23 09:49:15      阅读:324      评论:0      收藏:0      [点我收藏+]

说明:本系列是针对struct2学习过程,主要的目的:

1. 探索针对一个新的开源框架的学习过程。

2. 学习struct2,学习官方对struct2介绍的方法。

3.别把英语忘了。

1. 为了更加清晰的明白struct工程每个文件的意义,我们新建的是一个普通的java工程。

bubuko.com,布布扣

这个工程使用jetty直接调试,这样比较的方便,具体的见:jetty直接调试

需要注意的是:

WebAppContext webapp = new WebAppContext("WebRootFile", "/struct2"); 

文件名和工程名,与在建立工程的文件名和工程名称一样,就好。

测试工程:

bubuko.com,布布扣

ok了,准备工作完成。

添加struct2的支持,这个都比较的简单,直接贴张图吧。

bubuko.com,布布扣

下面的步骤,struct2的官方教程:

web.xml为:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
  <display-name></display-name>    
   <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
          org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
      </filter-class>
  </filter>
  <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>*.action</url-pattern>
  </filter-mapping>
</web-app>

structs.xml为:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
   <constant name="struts.devMode" value="true" />
 
    <package name="basicstruts2" extends="struts-default">
 
        <action name="index">
            <result>/index.jsp</result>
        </action>
 
    </package>
</struts>

 

ok,第一个struct完成。但是没有什么展示的效果比较的不能说明问题,下一步我们加一点展示的内容。

struct2(一)第一个struct程序

原文:http://www.cnblogs.com/zhailzh/p/3987567.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!