有没有源码呀

来源:2-2 Struts2 案例代码实现

慕斯卡5601479

2018-06-25 20:58

求源码

写回答 关注

4回答

  • 忧伤的民工
    2018-06-28 16:58:03
    已采纳
    web.xml

    <?xml version="1.0" encoding="UTF-8"?>

    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns="http://xmlns.jcp.org/xml/ns/javaee"

    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"

    id="WebApp_ID" version="3.1">

    <display-name>Struts2练习</display-name>

    <filter>

    <filter-name>struts2</filter-name>

    <!-- 特别说明如下 

    struts2.3版本路径是org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 

    struts2.5版本后路径是org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter -->

    <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>

    </filter>

    <filter-mapping>

    <filter-name>struts2</filter-name>

    <url-pattern>/*</url-pattern>

    </filter-mapping>

    </web-app>

    ---------------------------------------------------我是分割线--------------------------------------------

    struts.xml

    <?xml version="1.0" encoding="UTF-8" ?>

    <!DOCTYPE struts PUBLIC

        "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"

        "http://struts.apache.org/dtds/struts-2.5.dtd">

    <struts>

    <package name="default" namespace="/" extends="struts-default">

    <action name="HelloWorldAction" class="com.sadfoo.imooc.action.HelloWorldAction">

    <!-- 定义逻辑视图和物理资源之间的映射 -->

    <result name="success">/result.jsp</result>

    </action>

    </package>

    </struts>

    -------------------------------------------------------我是分隔符---------------------------------------------

    action(HelloWorldAction)

    package com.sadfoo.imooc.action;


    import com.opensymphony.xwork2.ActionSupport;


    /**

     * 

     * @author sadfoo 2018年6月28日下午12:41:09

     */

    @SuppressWarnings("serial")

    public class HelloWorldAction extends ActionSupport {

    /*

    * (non-Javadoc)

    * @see com.opensymphony.xwork2.ActionSupport#execute()

    */

    @Override

    public String execute() throws Exception {

    System.out.println("执行action");

    return SUCCESS;

    }

    }

    ---------------------------------------------------------我是分割线------------------------------------------

    result.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>练习struts2</title>

    </head>

    <body>

    <h1>This is my first JSP test page!</h1>

    </body>

    </html>

    ------------------------------------------------我是分割线--------------------------------------------

    访问地址和:http://localhost:8080/Struts2/HelloWorldAction.action

    qq_拓拔草...

    我现在报这个错是咋回事啊。我用的Tomcat9 Type Status Report Message There is no Action mapped for namespace [/] and action name [] associated with context path [/HelloWorld]. Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

    2018-09-13 22:36:54

    共 1 条回复 >

  • 慕粉1473922411
    2018-10-17 12:31:08

    谢谢楼主和回答者

  • qq_袮D影孑_03909390
    2018-08-15 12:58:20

    为什么我用了struts2.5版本后路径是org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter 后,tomacat无法启动,用了struts2.3版本路径是org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 这个后只是无法访问到网页

  • 忧伤的民工
    2018-06-28 17:20:36

    https://img.mukewang.com/5b34a8540001a3f602790202.jpg

    我用的是struts2.6.15  

    qq_袮D影...

    为什么我用了struts2.5版本后路径是org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter 后,tomacat无法启动,用了struts2.3版本路径是org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 这个后只是无法访问到网页

    2018-08-15 12:58:51

    共 1 条回复 >

Struts2入门

本教程带你踏上Struts2学习之旅,对Struts2进行更深入讲解

95063 学习 · 456 问题

查看课程

相似问题