zoukankan      html  css  js  c++  java
  • struts2模版搭建

    点击MyEclipse菜单栏File按钮,点击new-->Web Project

      

      输入Project name之后点击Finish

      项目创建完成。

      然后右键项目,点击MyEclipse-->Project Facets-->Install Apache Struts(2.x) Facets

      

      选择Struts2的版本,然后点击finish

      完成后的项目目录结构如下图所示:

      

      创建完之后在src下面可以看到struts.xml

      在src下创建action包,然后创建HelloWorldAction.java文件,内容如下:

      

    按 Ctrl+C 复制代码
    按 Ctrl+C 复制代码

      在src下面的struts.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>
        <package name="default"  extends="struts-default">
               <action name="helloworld" class="action.HelloWorldAction"> 
                   <result name="success">/result.jsp</result>
               </action>
       </package>
    </struts>    
    复制代码

      在WebRoot路径下添加result.jsp页面

    按 Ctrl+C 复制代码
    按 Ctrl+C 复制代码

      web.xml是自动生成的

    按 Ctrl+C 复制代码
    按 Ctrl+C 复制代码

      将项目部署到tomcat服务器,打开浏览器地址栏输入http://localhost:8080/struts2Demo/helloworld.action即可访问

      推荐学习视频(struts2入门):http://www.imooc.com/learn/464

  • 相关阅读:
    Python冒泡排序(4)
    Python冒泡排序(3)
    Python3默认递归最大深度是998
    Python利用递归函数和列表推导式实现快速排序
    天池比赛的文章--欢迎大家交流
    caffe学习笔记1
    网络压缩系列1:低秩逼近
    yolov1
    Windows下用Caffe跑自己的数据(遥感影像)
    基于灰度共生矩阵的纹理提取
  • 原文地址:https://www.cnblogs.com/ouyangping/p/6500682.html
Copyright © 2011-2022 走看看