完善了web.xml、first.jsp、showFirst.jsp的代码、新建springmvc.xml,配置Tomcat服务器,调试并运行

main
刘旭航 4 months ago
parent 146990062a
commit 56cda7d3ab

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,13 @@
<component name="ArtifactManager">
<artifact type="exploded-war" name="Flowers-SpringMVCProject-2205:Web exploded">
<output-path>$PROJECT_DIR$/out/artifacts/Flowers_SpringMVCProject_2205_Web_exploded</output-path>
<root id="root">
<element id="javaee-facet-resources" facet="Flowers-SpringMVCProject-2205/web/Web" />
<element id="directory" name="WEB-INF">
<element id="directory" name="classes">
<element id="module-output" name="Flowers-SpringMVCProject-2205" />
</element>
</element>
</root>
</artifact>
</component>

@ -0,0 +1,18 @@
<component name="libraryTable">
<library name="lib">
<CLASSES>
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/servlet-api.jar!/" />
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/spring-web-5.3.9.jar!/" />
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/spring-aop-5.3.9.jar!/" />
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/jsp-api.jar!/" />
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/commons-logging-1.2.jar!/" />
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/spring-core-5.3.9.jar!/" />
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/spring-webmvc-5.3.9.jar!/" />
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/spring-context-5.3.9.jar!/" />
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/spring-beans-5.3.9.jar!/" />
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/spring-expression-5.3.9.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Flowers-SpringMVCProject-2205.iml" filepath="$PROJECT_DIR$/Flowers-SpringMVCProject-2205.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
</component>
</module>

@ -0,0 +1,25 @@
<?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 http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- 配置注解扫描器配置spring容器初始化对象时需要扫描的包 -->
<context:component-scan base-package="com.ssm.controller"></context:component-scan>
<!-- 配置视图解析器,ctrl+shift+t搜索类将return的字符串逻辑视图+前缀+后缀,转换成真正的物理视图 -->
<!-- 逻辑视图success,真正的视图:/WEB-INF/view/success.jsp -->
<!-- -->
<!-- 配置注解驱动 -->
<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="/WEB-INF/view/"></property>
<!-- 后缀 -->
<property name="suffix" value=".jsp"></property>
</bean>
<bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
</bean>
</beans>

@ -0,0 +1,12 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>展示入门程序信息</title>
</head>
<body>
Success!
</body>
</html>

@ -0,0 +1,31 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>展示Controller接收及响应数据</title>
</head>
<body>
Success!
<br>
商品信息已在控制台输出!
<%--<br>--%>
<%--商品名称:${productInfo.pname}--%>
<%--<br>--%>
<%--是否热门:${productInfo.isHot}--%>
<%--<br>--%>
<%--市场价格:${productInfo.marketPrice}--%>
<%--<br>--%>
<%--销售价格:${productInfo.shopPrice}--%>
<%--<br>--%>
<%--商品图片:${productInfo.image}--%>
<%--<br>--%>
<%--分类名称:${productInfo.category.cname}--%>
<%--<br>--%>
<%--商品描述:${productInfo.pdesc}--%>
<%--<br>--%>
<%--上架日期:${productInfo.pdate}--%>
</body>
</body>
</html>

@ -0,0 +1,16 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>展示花卉类目信息</title>
</head>
<body>
Success!
<br>
类目编号:${itemCategoryInfo.id}
<br>
类目名称:${itemCategoryInfo.name}
</body>
</html>

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>SpringMVCFirst</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>springDispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 配置DispatcherServlet的初始化参数 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<!-- 配置SpringMVC配置文件的位置和名称-->
<param-value>classpath:springmvc.xml</param-value>
</init-param>
<!-- 该servlet在第一次加载的时候就被创建而不是等请求时才创建 -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springDispatcherServlet</servlet-name>
<!-- 可以应答所有请求 -->
<url-pattern>/</url-pattern>
</servlet-mapping>
<!--编码过滤器,解决中文乱码问题-->
<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>
</web-app>

@ -0,0 +1,67 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加花卉</title>
</head>
<body>
<form action="item/add" method="post">
<table>
<tr>
<td>花卉编号:</td>
<td width="20"></td>
<td><input type="text" name="id" placeholder="请输入花卉编号" /></td>
</tr>
<tr>
<td>花卉名称:</td>
<td width="20"></td>
<td><input type="text" name="name" placeholder="请输入花卉名称" /></td>
</tr>
<tr>
<td>花卉价格:</td>
<td width="20"></td>
<td><input type="text" name="price" value="" class="bg" placeholder="请输入花卉价格" /></td>
</tr>
<tr>
<td>折扣:</td>
<td width="20"></td>
<td><input type="text" name="zk" value="" placeholder="请输入折扣" /></td>
</tr>
<tr>
<td>花卉一级类目:</td>
<td width="20"></td>
<td><input type="text" name="yiji.name" placeholder="请输入一级类目" /></td>
</tr>
<tr>
<td>花卉二级类目:</td>
<td width="20"></td>
<td><input type="text" name="erji.name" placeholder="请输入二级类目" /></td>
</tr>
<tr>
<td>商品主图:</td>
<td width="20"></td>
<td><input type="file" name="url1" /></td>
</tr>
<tr>
<td>副图1</td>
<td width="20"></td>
<td><input type="file" name="url2" /></td>
</tr>
<tr>
<td>描述:</td>
<td width="20"></td>
<td><textarea name="ms" rows="5" cols="35"></textarea></td>
</tr>
<tr>
<td align="right"><input type="reset" value="重置"></td>
<td></td>
<td align="center">
<input type="submit" value="添加">
</td>
</tr>
</table>
</form>
</body>
</html>

@ -0,0 +1,19 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加花卉类目信息</title>
</head>
<body>
<form action="itemCategory/add" method="post">
类目编号:<input type="text" name="id">
<br>
类目名称:<input type="text" name="name">
<br>
<input type="submit" value="添加">
</form>
</body>
</html>

@ -0,0 +1,12 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>入门程序</title>
</head>
<body>
<a href="hello">hello world</a>
</body>
</html>

@ -0,0 +1,25 @@
<?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 http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- 配置注解扫描器配置spring容器初始化对象时需要扫描的包 -->
<context:component-scan base-package="com.ssm.controller"></context:component-scan>
<!-- 配置视图解析器,ctrl+shift+t搜索类将return的字符串逻辑视图+前缀+后缀,转换成真正的物理视图 -->
<!-- 逻辑视图success,真正的视图:/WEB-INF/view/success.jsp -->
<!-- -->
<!-- 配置注解驱动 -->
<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="/WEB-INF/view/"></property>
<!-- 后缀 -->
<property name="suffix" value=".jsp"></property>
</bean>
<bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
</bean>
</beans>
Loading…
Cancel
Save