There is no action mapped for namespace [/] and Action name [Login] associated with context path [/E

Source: Internet
Author: User

This is a headache when learning web development in the near future.

Baidu Google N Times, finally in the blog http://blog.csdn.net/liu578182160/article/details/17266879 found the root of the problem.

Development environment: Win7 32-bit flagship edition, jdk1.7_45,jre7,eclipse4.3.1 Java EE Edition, Tomcat 7.0.42,struts2.3.16.3


The problem is now that the Web. XML configuration

Original Web. xml:

<?xml version= "1.0" encoding= "UTF-8"? ><web-app id= "Struts2demo" version= "2.4" xmlns= "http://java.sun.com/ Xml/ns/j2ee "  xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "  xsi:schemalocation="/http/ JAVA.SUN.COM/XML/NS/J2EE   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">        <filter>        < filter-name>struts2</filter-name>        <filter-class>        Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter        </filter-class>    </ filter>    <filter-mapping>        <filter-name>struts2</filter-name>        <url-pattern >/*</url-pattern>    </filter-mapping></web-app>

Modified Web. xml:

<?xml version= "1.0" encoding= "UTF-8"?>  <web-app version= "3.0"       xmlns= "http://java.sun.com/xml/ns/ Java ee "       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_3_0.xsd ">    <display-name></ display-name>          <filter>       <filter-name>struts2</filter-name>       <filter-class >org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>    </filter >    <filter-mapping>       <filter-name>struts2</filter-name>       <url-pattern>/ *</url-pattern>    </filter-mapping>        <welcome-file-list>      <welcome-file> login.jsp</welcome-file>    </welcome-file-list>  </web-app>

The key difference is the Web-app version.

(It does not seem to be the issue of this version number, just tried the 2.4 web-app, can carry out success.) )


Maybe this is not the key to the problem, where the project changes are

Original login.jsp:

<%@ page language= "java" import= "java.util.*" pageencoding= "utf-8"%><%string path = Request.getcontextpath () ; String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >

Login.jsp after the change:

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "    pageencoding=" UTF-8 "%><% @taglib prefix=" s "uri="/struts-tags "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.