lusufei

此博客用于个人备份与复习

导航

Struts2--HelloWord

   Struts2官网

   官网指南

 

   官网下载Struts2.5-min-lib.zip解压把lib目录下jar包拷贝到web项目lib目录下

 

配置web.xml文件

 <filter>
        <filter-name>action2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <!-- END SNIPPET: filter -->

    <filter-mapping>
        <filter-name>action2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
<!-- 注意2.3版本略有不同具体看官网指南 -->

 struts.xml 新建在src目录下

<struts>

    <package name="helloword" extends="struts-default">
      <action name="hello">
         <result>/WEB-INF/pages/hello.jsp</result>
      </action>
    </package>

</struts>

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    
    <a href="hello.action">hello</a>
    
</body>
</html>

运行项目跳转

 

posted on 2017-08-02 10:13  lusufei  阅读(159)  评论(0编辑  收藏  举报