zoukankan      html  css  js  c++  java
  • MyEclipse2014配置2.5版本的struts2

    原创


    配置struts2一般来说需要以下步骤:

    • 将项目所需要的Jar包导入项目webRoot/WEB-INF/lib下(包不追求多,容易导致冲突或者其他问题,需要多少导入多少)
    • 配置struts.xml文件
    • 配置web.xml文件

    2.5版本的struts2 链接:https://pan.baidu.com/s/1KnEh3UvucUvjHV9P4yTKNw 密码:kssr

    在MyEclipse2014中可以按如下步骤进行配置:

    一、

    解压上面的压缩包

    进入apps解压struts2-rest-showcase.war,解压后进入appsstruts2-rest-showcaseWEB-INFlib下将以下9个包拷贝进入项目的webRoot/WEB-INF/lib下

    如果自己项目需要更多的包可选择更多

    二、

    将目录appsstruts2-rest-showcaseWEB-INFsrcjava下的struts.xml文件拷贝到本身项目src下面

    配置完后修改struts.xml文件

    <package name="rest-showcase" extends="struts-default">
         <global-allowed-methods>index,show,create,update,destroy,deleteConfirm,edit,editNew</global-allowed-methods>
            <action name="outPut" class="Action.hello">
                <result name="helloWorld">/index.jsp</result>
            </action>
    </package>

    三、

    然后修改web.xml文件

    <filter>
          <filter-name>struts2</filter-name>
          <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
      </filter>
      <filter-mapping>
          <filter-name>struts2</filter-name>
          <url-pattern>/*</url-pattern>
      </filter-mapping>
    对于org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter,有些旧版本的struts2可能是
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
    index.jsp的内容如下:
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'index.jsp' starting page</title>
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">    
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
      </head>
      
      <body>
        第一个Struts2<br>
      </body>
    </html>

    对于struts.xml的一些参数讲解看:https://blog.csdn.net/qq_25827845/article/details/53205941

    22:07:57

    2018-11-07

  • 相关阅读:
    Python3-接口自动化-6-unittest模块的各个属性说明
    Python3-接口自动化-5-JSON和字典的区别
    Python3-接口自动化-4-GET和POST请求
    Python3-接口自动化-3-接口自动化项目目录框架
    数据库2
    IO多路复用
    协程--代码注释篇
    协程--理论篇
    线程--代码注释篇
    线程--理论篇
  • 原文地址:https://www.cnblogs.com/chiweiming/p/9926108.html
Copyright © 2011-2022 走看看