一、问题描述
      使用idea itellij开发工具进行Maven工程创建并搭建SpringMVC框架,配置检查了许多遍没有问题,通过直接物理路径可以进行访问,但是Requestmapping 不能访问到,会报错404,idea这边也没有任何报错。

二、解决思路
      1.熟悉SpringMVC的工作流程,弄清楚工作原理

2.根据404报错提示进行检查路径(这也是大多博客所建议的方案),包括大小写有无写错(提醒,return 那个返回路径鼠标放在上面应该会弹出该路径(你所创建的JSP路径))。

3.进行环境配置检查,这一步不要忽略,很多刚开始学习的新人容易觉得是配置的问题,但是大多情况可能出在环境配置上。而我正好就出在这上面。

三、创建过程
      我看到有些博文说了很多解决办法但是就是没有给出详细的配置过程,所以说不利于对比解决问题,为了更好的解决问题,我把我创建过程放出来。
      1.安装配置环境
      (1)tomcat的环境配置,为保证正确,建议设置一下环境变量,教程百度很多,也比较简单,只要能用localhost:8080访问到基本上没有什么问题。
      (2)JDK,建议采用idea下载的open jdk 14 ,也可以自己到jdk官网下载配置环境变量。
      (3)maven:无需再进行下载,直接改了maven工程的setting.xml增添阿里云库镜像。
      2.maven工程创建
      (1)配置文件

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"><display-name>Archetype Created Web Application</display-name><!--文字过滤器--><filter><filter-name>characterEncodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param></filter><filter-mapping><filter-name>characterEncodingFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicatonContext.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><servlet><servlet-name>dispatcher-servlet</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:dispatcher-servlet.xml</param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>dispatcher-servlet</servlet-name><url-pattern>*.action</url-pattern></servlet-mapping></web-app>

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"></beans>

dispatcher-servlet(spring-mvc)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"><!--自动扫描包--><context:component-scan base-package="com.lyf.Controller"/><!-- 默认的注解映射支持--><mvc:annotation-driven><mvc:message-converters><bean class="org.springframework.http.converter.StringHttpMessageConverter"/><bean class="org.springframework.http.converter.ResourceHttpMessageConverter"/></mvc:message-converters></mvc:annotation-driven><bean id="viewResolver"class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/pagejump/"/><property name="suffix" value=".jsp"/></bean><mvc:default-servlet-handler/></beans>

增添阿里库

<?xml version="1.0" encoding="UTF-8"?><!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
--><!--| This is the configuration file for Maven. It can be specified at two levels:||  1. User Level. This settings.xml file provides configuration for a single user,|                 and is normally provided in ${user.home}/.m2/settings.xml.||                 NOTE: This location can be overridden with the CLI option:||                 -s /path/to/user/settings.xml||  2. Global Level. This settings.xml file provides configuration for all Maven|                 users on a machine (assuming they're all using the same Maven|                 installation). It's normally provided in|                 ${maven.conf}/settings.xml.||                 NOTE: This location can be overridden with the CLI option:||                 -gs /path/to/global/settings.xml|| The sections in this sample file are intended to give you a running start at| getting the most out of your Maven installation. Where appropriate, the default| values (values used when the setting is not specified) are provided.||-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"><!-- localRepository| The path to the local repository maven will use to store artifacts.|| Default: ${user.home}/.m2/repository<localRepository>/path/to/local/repo</localRepository>--><!-- interactiveMode| This will determine whether maven prompts you when it needs input. If set to false,| maven will use a sensible default value, perhaps based on some other setting, for| the parameter in question.|| Default: true<interactiveMode>true</interactiveMode>--><!-- offline| Determines whether maven should attempt to connect to the network when executing a build.| This will have an effect on artifact downloads, artifact deployment, and others.|| Default: false<offline>false</offline>--><!-- pluginGroups| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.|--><pluginGroups><!-- pluginGroup| Specifies a further group identifier to use for plugin lookup.<pluginGroup>com.your.plugins</pluginGroup>--></pluginGroups><!-- proxies| This is a list of proxies which can be used on this machine to connect to the network.| Unless otherwise specified (by system property or command-line switch), the first proxy| specification in this list marked as active will be used.|--><proxies><!-- proxy| Specification for one proxy, to be used in connecting to the network.|<proxy><id>optional</id><active>true</active><protocol>http</protocol><username>proxyuser</username><password>proxypass</password><host>proxy.host.net</host><port>80</port><nonProxyHosts>local.net|some.host.com</nonProxyHosts></proxy>--></proxies><!-- servers| This is a list of authentication profiles, keyed by the server-id used within the system.| Authentication profiles can be used whenever maven must make a connection to a remote server.|--><servers><!-- server| Specifies the authentication information to use when connecting to a particular server, identified by| a unique name within the system (referred to by the 'id' attribute below).|| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are|       used together.|<server><id>deploymentRepo</id><username>repouser</username><password>repopwd</password></server>--><!-- Another sample, using keys to authenticate.<server><id>siteServer</id><privateKey>/path/to/private/key</privateKey><passphrase>optional; leave empty if not used.</passphrase></server>--></servers><!-- mirrors| This is a list of mirrors to be used in downloading artifacts from remote repositories.|| It works like this: a POM may declare a repository to use in resolving certain artifacts.| However, this repository may have problems with heavy traffic at times, so people have mirrored| it to several places.|| That repository definition will have a unique id, so we can create a mirror reference for that| repository, to be used as an alternate download site. The mirror site will be the preferred| server for that repository.|--><mirrors><!-- mirror| Specifies a repository mirror site to use instead of a given repository. The repository that| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.|<mirror><id>mirrorId</id><mirrorOf>repositoryId</mirrorOf><name>Human Readable Name for this Mirror.</name><url>http://my.repository.com/repo/path</url></mirror>-->
<mirror>
<id>aliyun</id>
<name>aliyun Maven</name>
<mirrorOf>*</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<!-- <url>http://maven.oschina.net/content/groups/public</url> -->
</mirror></mirrors><!-- profiles| This is a list of profiles which can be activated in a variety of ways, and which can modify| the build process. Profiles provided in the settings.xml are intended to provide local machine-| specific paths and repository locations which allow the build to work in the local environment.|| For example, if you have an integration testing plugin - like cactus - that needs to know where| your Tomcat instance is installed, you can provide a variable here such that the variable is| dereferenced during the build process to configure the cactus plugin.|| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles| section of this document (settings.xml) - will be discussed later. Another way essentially| relies on the detection of a system property, either matching a particular value for the property,| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.| Finally, the list of active profiles can be specified directly from the command line.|| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact|       repositories, plugin repositories, and free-form properties to be used as configuration|       variables for plugins in the POM.||--><profiles><!-- profile| Specifies a set of introductions to the build process, to be activated using one or more of the| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>| or the command line, profiles have to have an ID that is unique.|| An encouraged best practice for profile identification is to use a consistent naming convention| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.| This will make it more intuitive to understand what the set of introduced profiles is attempting| to accomplish, particularly when you only have a list of profile id's for debug.|| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.<profile><id>jdk-1.4</id><activation><jdk>1.4</jdk></activation><repositories><repository><id>jdk14</id><name>Repository for JDK 1.4 builds</name><url>http://www.myhost.com/maven/jdk14</url><layout>default</layout><snapshotPolicy>always</snapshotPolicy></repository></repositories></profile>--><!--| Here is another profile, activated by the system property 'target-env' with a value of 'dev',| which provides a specific path to the Tomcat instance. To use this, your plugin configuration| might hypothetically look like:|| ...| <plugin>|   <groupId>org.myco.myplugins</groupId>|   <artifactId>myplugin</artifactId>||   <configuration>|     <tomcatLocation>${tomcatPath}</tomcatLocation>|   </configuration>| </plugin>| ...|| NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to|       anything, you could just leave off the <value/> inside the activation-property.|<profile><id>env-dev</id><activation><property><name>target-env</name><value>dev</value></property></activation><properties><tomcatPath>/path/to/tomcat/instance</tomcatPath></properties></profile>--></profiles><!-- activeProfiles| List of profiles that are active for all builds.|<activeProfiles><activeProfile>alwaysActiveProfile</activeProfile><activeProfile>anotherAlwaysActiveProfile</activeProfile></activeProfiles>-->
</settings>

3.具体过程
(1)创建maven过程

点击archetype\选择maven-archetype-webapp

暂时采用本地库和setting.xml,一会儿添加


如果大家觉得此篇文章写得有不足之处,望指出;若觉得还不错,希望大家关注支持一下。

关于页面访问 404的具体解决办法相关推荐

  1. iis打开php网页404,遇到IIS7配置PHP出现403和404错误的解决办法

    服务器要配置PHP,总是出现403错误.服务器是新装的,操作系统是windows server 2008 R2,装的IIS7. IIS里PHP和本地服务器对比了好几遍,都没到出错的原因,后来通过cmd ...

  2. 给大家推荐一个Vue 单页面程序无法SEO的解决办法

    给大家推荐一个vue 单页面搜索引擎无法SEO的解决办法 这两天用Vue3做了一个免费下载书籍的小网站,https://book.usejs.cn:大家可以先看下效果 前端项目做完.部署了之后想让搜索 ...

  3. 阿里云服务器安全组配置-有关访问实例异常的解决办法

    阿里云服务器安全组配置-有关访问实例异常的解决办法 参考文章: (1)阿里云服务器安全组配置-有关访问实例异常的解决办法 (2)https://www.cnblogs.com/ylcxBlog/p/7 ...

  4. Nuget 管理报repositories.config 访问路径被拒绝 解决办法

    Nuget 管理报repositories.config 访问路径被拒绝 解决办法 就是把packages/repositories.config 删除 再管理更新 即可 生成最新的repositor ...

  5. 内网用户通过域名或公网IP访问内部服务器的解决办法

    内网用户通过域名或公网IP访问内部服务器的解决办法 原因-路由回流 组网图 解决方案 内部NAT方案 内网用户与服务器不同网段 E0/0和E0/2都需要做nat server 内网用户与服务器相同网段 ...

  6. 浏览器无法访问gitlab.nicky.com解决办法

    浏览器无法访问gitlab.nicky.com解决办法 1. 找到可以访问到该地址的主机,cmd窗口查看 2. 把其配置在访问不到的主机host里. 1. 找到可以访问到该地址的主机,cmd窗口查看 ...

  7. Nginx启动成功但页面访问不到的解决方法

    解决Nginx启动成功但页面访问不到的解决方法: 1.首先查看Nginx进程:ps -ef | grep nginx 如图所示,代表Nginx启动成功.(相关阅读推荐:Nginx启动不起来怎么办) 2 ...

  8. 有关阿里云服务器ping不通解决办法(云服务器搭建完环境访问不了ip解决办法)

    阿里云服务器ping不通解决办法(云服务器搭建完环境访问不了ip解决办法) 问题:这里的服务器我以阿里云为例,学生套餐嘛,便宜,最近搞服务器,然后Ubuntu16.04下搭建LAMP环境后发现输入ip ...

  9. ireport生成html横线多出,iReport4.5.1、Struts2.2.3生成Html文档时页面红叉叉的解决办法。...

    iReport4.5.1.Struts2.2.3生成Html文档时页面红叉叉的解决办法. 这些个小红叉叉甚的恼人! 解决方法如下: 而且后台报错: 提示找不到名字为px的action 警告: Coul ...

最新文章

  1. 提升Web应用程序性能的最佳实践
  2. Windows 7 自动更新失败导致无法进系统解决方案
  3. Python 中 with 用法详解
  4. 基于Spring安全角色的访问授权示例
  5. VC++视频教程下载地址
  6. WebService 的CXF框架 WS方式Spring开发
  7. Anaconda下载太慢问题解决
  8. 【0.96OLED屏幕】原理图及SSD1306引脚功能
  9. 【转载】装机知识显卡篇,一篇文章让小白透彻的了解显卡
  10. wrk 服务器性能HTTP压测工具
  11. ffmpeg - 视频裁剪
  12. 干货分搞私投以技术面试
  13. 直男届的杀手-『小冰』架构解析
  14. 数学乐 --- 奇函数与偶函数(个人学习笔记)
  15. 如何隐藏电脑硬盘分区
  16. Go语言进阶,结构体与json字符串格式的互相转换
  17. 2016区域赛前冲刺训练
  18. Myeclipse中安装mybatis generator插件有两种方式,一种是在线安装,一种是离线安装。
  19. 饥荒专属服务器证书过期,饥荒TGP版存档丢失及证书不存在解决方法介绍
  20. Window下的2D游戏-贴图技术

热门文章

  1. 【数据分析】python带你分析122万人的生活工作和死亡数据
  2. vue路由第三篇-导航守卫、路由元信息、动态路由
  3. 学生社团管理系统c语言代码,毕业设计—校园社团活动助手小程序
  4. c语言15-puzzle解法,15 Puzzle (4乘4谜题) IDA*(DFS策略与曼哈顿距离启发) 的C语言实现...
  5. 【工具】VSCode无法正常启动Terminal窗口
  6. 如何批量OCR识别各类票据关键信息,导出为结构化格式数据
  7. YOLOv5数据集划分脚本(train、val、test)
  8. 御坂坂的C++学习之路(1)
  9. mysql按时间查询的优化_mysql按时间查询优化的方法
  10. 怎么复制黑苹果config配置_黑苹果主机(百分百成功硬件配置)