题目:定义一个员工实体(Employee),实现批量添加员工功能,在表单中可以一次添加多个员工,数据可以不持久化
1,新建一个项目
2, 然后选择Maven框架选择 maven-archetype-webapp 再--->Next
填写 GroupId、 ArtifactId
选择配置(选择自己的Maven本地仓库等等...)
选择自动导入
为了“ [ ]” 能通过请求还中文tk,把Tomcat修改conf/server.xml文件,如下所示:
如果不记得Tomcat的位子 方法如下:
自动导入后打开 pom.xml 添加版本号
4.3.0.RELEASE
再把依赖包导入
org.springframework
spring-context
${spring.version}
org.springframework
spring-webmvc
${spring.version}
javax.servlet
jstl
1.2
javax.servlet
javax.servlet-api
3.0.1
provided
javax.servlet.jsp
jsp-api
2.1
provided
View Code
打开 web.xml 修改
复制下面代码粘贴入
springmvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath*:springmvc-servlet.xml
1
springmvc
/
View Code
但是会有一处报错 因为还没有新建 pringmvc-servlet.xml 文件
下面创建 java resources 并且指定文件类型
Shift+Ctrl+Alt+S 打开
指定文件类型
在resources 下新建 pringmvc-servlet.xml 文件
复制下面代码粘贴入
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
View Code
然后看几处报错误,没关系等下新建几个包就好了
接下来 在 WEB-INF 下的views下的foo新建 addStaff.jsp 文件
User: XIHEHUADate:2018/10/25
Time:20:06
Tochange this template use File | Settings | File Templates.--%>
Title}.text{width:800px;height:900px;margin:0 auto;
}
员工信息
员工编号姓名性别学历月薪增加移除--请选择--
男
女
保密
--请选择--
高中
专科
本科
重点
硕士
批量添加