发表于: 2016-10-16 22:30:43
4 2080
今天完成的事情:修改以前备份的任务代码,处理环境报错问题,
明天计划的事情:解决表单提交转换成对象的问题,如果不行,先使用笨办法完成代码打一个war包先发布吧。
遇到的问题:
1.
one or more constraints have not been satisfied
意思是一个或多个约束条件没有得到满足
2.
cannot change version of project facet dynamic web module to 3.0
不能更改项目方面动态web模块的版本为3.0
这里是因为我web.xml中配置的version是3.0,解决的办法是修改项目路径/.setting/文件,
https://my.oschina.net/cloudcoder/blog/362949
将所有1.5的地方换成1.7,在org.eclipse.wst.common.project.facet.core.xml 中我发现自己的jst.web
的version是2.3,我修改成了3.0,然而错误还是没有消除。。。。
3.
@Autowired和@Resource的区别,
@Autowired注释使用的是byType方式注入
@Resource注释使用的是byName方式注入
http://blog.csdn.net/gst6062825/article/details/8765157
上面这篇blog总结了一下这两个注释
关于byName和byType
byName方式是通过Bean的id或者name来注入的,
byType方式是通过Class类型来注入的
可以参考书籍《spring in action》
4.
jetty:run命令启动失败
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
BUILD FAILURE
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ITTast:
Compilation failure[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
http://blog.csdn.net/fox_lht/article/details/16369147
这个blog可以解决
这里的意思是需要配置执行环境
需要使用jdk而不是jre启动,jdk是开发工具包,jre是运行环境
5.
form表单提交地址总是加上了文件夹jsp
使用${pageContext.request.contextPath}
它等价于<%=request.getContextPath()%>,意思就是去除部署的应用程序名或者当前的项目名称
6.
java.io.FileNotFoundException: D:\logs\ITXZY\error.log (系统找不到指定的路径。)
这里需要手动创建一下ITXZY
7.
Required Userinfo parameter 'user' is not present
这里我想使用@RequestParam注释自动装配表单提交的内容到指定的用户类中
spring mvc 如何将表单映射为对象
这里我使用了@RequestParam @ModelAttribute,或者不写注释都不能实现,后面干脆报404 NOT_FOUND
可是控制台的到的是
Publishing event in WebApplicationContext for namespace 'DispatcherServlet-servlet': ServletRequestHandledEvent:
url=[/ITTest/ITTest/user/insert]; client=[0:0:0:0:0:0:0:1]; method=[POST]; servlet=[DispatcherServlet];
session=[irmfu3olrzxr13gz0p2uwi6ro]; user=[null]; time=[10ms]; status=[OK]
user就是为null,这里可能是我搜索关键字不对吧,没有找到解决办法
8.
想要访问静态资源的时候要注意配置路径,不然在web.xml中配置/作为DispatcherServlet的值,他就会拦截所有的请求了,
这里需要再spring-mvc.xml中配置<mvc:resources>节点
<mvc:resources mapping="/resources/**" location="/resources/" />
mapping:映射
location:本地资源路径,注意必须是webapp根目录下的路径。
两个*,它表示映射resources/下所有的URL,包括子路径(即接多个/)
9.web.xml中的一般会配置两个地址,一开始疏忽了改成了CharacterEncodingFilter,
CharacterEncodingFilter是字符过滤器
DispatcherServlet才是拦截请求的映射器
如果只将CharacterEncodingFilter的链接修改为/*.do,页面上
那么访问静态资源insert.jsp后页面上
<form action="<%=request.getContextPath()%>/user/insert" method="post">
会被解析成<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
http://www.cnblogs.com/mailingfeng/archive/2012/04/05/2432687.html
这里需要了解下url-pattern节点是怎么定义的
还有 Context Path + servlet path + path info = request uri这个关系
评论