When configuring my first struts 2, I created a new web project in MyEclipse 8.6, and then the web.xml under Webroot/WEB-INF is automatically generated. The XML header file information is:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
When I filled in the code for configuring Struts2, I reported an error:
1. Struts 2 Code:
<display-name>My First struts2 Programmer</display-name> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
2. Error:
Multiple annotations found at this line: - cvc-complex-type.2.3: Element 'web-app' cannot have character [children], because the type's content type is element-only.
Later, it was found that there was no problem with the Struts2 configuration code, but with the third line in the XML header file:
xmlns=” http://java.sun.com/xml/ns/javaee ”
Maybe it’s the habit of using J2EE all the time? It’ll be fine after it’s changed to J2EE anyway