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 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序