# springmvc
**Repository Path**: smartwan/springmvc
## Basic Information
- **Project Name**: springmvc
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-12-31
- **Last Updated**: 2026-01-13
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
> https://www.cnblogs.com/lockegogo/p/18013103#_label6
## idea问题记录
1. idea反复设置,需要将.gitignore文件中一下注释掉
```test
#.idea/modules.xml
#.idea/jarRepositories.xml
#.idea/compiler.xml
#.idea/libraries/
```
- 使用技巧:在 idea失效重启前push代码,重启后pull代码,确保idea配置的延续性。
## tomcat配置
> 新建模块testOne 用来跑通tomcat服务
1. **在父级目录创建子目录testOne**
- 在pom.xml中添加依赖
2. **在idea 文件-项目结构中创建** 模块testOne,并配置 web 下 创建的目录claasses和lib
- 注意路径输出目录、测试输出目录必须对应classes和lib
- 依赖必须引入 servlet-api (从tomcat的lib中引入)
3. **在模块testOne下添加** web ,检查描述符
4. **创建工件**,在右侧可用元素中将 testOne 添加到工件中
5. **最后在tomcat中引入工件**
- 运行-编辑配置
- 配置-tomcat主目录中引入tomcat所在目录
- 部署中引入工件
6. 依然无法正常访问:
- 到 java/xxx/xx.java查看提示:IDEA-Java文件位于模块源根之外,因此不会被编译
- 在项目结构中 找到对应的 java目录标记为 源代码
- https://blog.csdn.net/qq_41684621/article/details/143483202
## springmvc配置
> 新建模块testTwo 用来实现mvc项目
1. 改造web.xml
- 将servlet相关配置,指向文件 :springmvc-servlet.xml (resources/springmvc-servlet.xml)
2. 新建文件:springmvc-servlet.xml
- 将controller中的类交给 SpringIOC 容器,注册 bean : springmvc-servlet1.xml
```java
```
- 为了支持基于注解的 IOC,设置了自动扫描包的功能: springmvc-servlet.xml,对应HelloController
- 报错:Request processing failed: java.lang.IllegalArgumentException: Name for argument of type [int] not s
```java
@PathVariable(value="p1") int p1; // 使用该注解时应该给value指出对应的参数
```
## Json
> 新建模块testThree 返回json格式数据
1. org.apache.catalina.core.StandardContext.filterStart Exception starting filter [encoding
- 文件-项目结构-工件-testThree-web/WEB-INF/lib - 加号 - 库文件 - 选中 导入 -应用
2. 'org.springframework.web.servlet.DispatcherServlet'未分配到 javax.servlet.Servlet
- pom.xml安装jakarta.servlet相关依赖,添加build配置
- spring-webmvc版本改为:6.1.10
3. java.lang.IllegalArgumentException:
More than one fragment with the name [spring_web] was found. This is not legal with relative ordering.
See section 8.2.2 2c of the Servlet specification for details. Consider using absolute ordering.
- web.xml最后加上
- spring-framework-bom 版本同 com.fasterxml.jackson.core 版本不兼容导致报错
4. FastJson
- fastjson.jar :实现 json 对象与 JavaBean 对象的转换
- JavaBean 对象与 json 字符串的转换
- json 对象与 json 字符串的转换
- src/main/java/com/www/testThree/controller/FastJsonDemo.java
## 常见错误:
1. org.apache.catalina.core.StandardContext.startInternal Context [/four] startup failed due to previous errors
- 依赖缺失,在 文件 - 项目结构 - 工件 - 输出布局 - WEB-INF下 新建文件夹 lib,然后添加 库文件