headshot1 2019-03-01 21:46 采纳率: 25%
浏览 808

新手,使用Intellij Idea测试Struts2遇到的问题

Idea版本为2018.3,按照提示,Struts2版本为2.5.14,配置完毕,遇到了问题。

第一个问题就是log4j的错误,经过各种尝试,删除out-》artifact-》module-》web-inf-》web.xml,可以正常部署。

然后加入Struts2内容,跳转action时遇到404,请帮忙看看什么问题。

web.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <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>
</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="first" namespace="/" extends="struts-default">
        <action name="test" class="com.opensymphony.xwork2.ActionSupport" method="execute">
            <result name="success">/success.jsp</result>
        </action>
    </package>
</struts>

index.jsp如下:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>$Title$</title>
</head>
<body>
<form action="test.action" method="post"><input type="submit"/></form>

</body>
</html>
  • 写回答

2条回答 默认 最新

  • headshot1 2019-03-01 22:24
    关注

    https://blog.csdn.net/skullFang/article/details/78202338

    完美解决!!!

    主要是下载官网提供的最新的min包就可以了,使用Idea下载的有问题

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog