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>