当前位置: 首页 > news >正文

普洱网站建设优化网站建设的流程是什么

普洱网站建设优化,网站建设的流程是什么,网站设计目的怎么写,北京广告公司标牌制作文章目录 一、环境准备二、配置 web.xml三、配置 SpringMVC-Servlet.xml ,这里不再使用之前那种写法,直接采用注解配置,引入注解支持,配置视图解析器四、编写 Controller(Controller 和 RequestMapping 注解说明&#…

文章目录

  • 一、环境准备
  • 二、配置 web.xml
  • 三、配置 SpringMVC-Servlet.xml ,这里不再使用之前那种写法,直接采用注解配置,引入注解支持,配置视图解析器
  • 四、编写 Controller(@Controller 和 @RequestMapping 注解说明)
  • 五、编写要跳转的jsp页面,显示ModelandView存放的数据




一、环境准备


  • 1、创建 maven 项目,添加框架支持

  • 2、添加依赖,因为 maven 可以有一些资源过滤的问题,这里直接将资源过滤配置补全

    <dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>5.1.9.RELEASE</version></dependency><!-- 导入servlet 和 jsp 的 jar 依赖 --><dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><version>2.5</version></dependency><dependency><groupId>javax.servlet.jsp</groupId><artifactId>jsp-api</artifactId><version>2.2</version></dependency><dependency><groupId>javax.servlet</groupId><artifactId>jstl</artifactId><version>1.2</version></dependency>
    </dependencies><build><resources><resource><directory>src/main/java</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource><resource><directory>src/main/resources</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource></resources>
    </build>
    
  • 3、检查项目结构中是否有 lib 夹以及 jar 是否成功导入了,并配置 tomcat



二、配置 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"><!--1.注册servlet--><servlet><servlet-name>SpringMVC</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><!--通过初始化参数指定SpringMVC配置文件的位置,进行关联--><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:SpringMVC-Servlet.xml</param-value></init-param><!-- 启动顺序,数字越小,启动越早 --><load-on-startup>1</load-on-startup></servlet><!--所有请求都会被springmvc拦截 --><servlet-mapping><servlet-name>SpringMVC</servlet-name><url-pattern>/</url-pattern></servlet-mapping></web-app>


三、配置 SpringMVC-Servlet.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"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttps://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/mvchttps://www.springframework.org/schema/mvc/spring-mvc.xsd"><!-- 自动扫描包,让指定包下的注解生效,由IOC容器统一管理 --><context:component-scan base-package="com.sys.controller"/><!-- 让Spring MVC不处理静态资源:HTML,JS,CSS,图片,视频等 --><mvc:default-servlet-handler/><!-- 支持mvc注解驱动在spring中一般采用@RequestMapping注解来完成映射关系要想使@RequestMapping注解生效必须向上下文中注册DefaultAnnotationHandlerMapping和一个AnnotationMethodHandlerAdapter实例这两个实例分别在类级别和方法级别处理。而annotation-driven配置帮助我们自动完成上述两个实例的注入。--><mvc:annotation-driven /><!-- 视图解析器 --><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"id="internalResourceViewResolver"><!-- 前缀 --><property name="prefix" value="/WEB-INF/jsp/" /><!-- 后缀 --><property name="suffix" value=".jsp" /></bean></beans>
    


四、编写 Controller(@Controller 和 @RequestMapping 注解说明)

  • @Controller:

    @Controller 用于标记在一个类上,使用它标记的类就是一个SpringMVC Controller 对象(控制器)。分发处理器将会扫描使用了该注解的类的方法,并检测该方法是否使用了@RequestMapping 注解。@Controller 只是定义了一个控制器类,而使用@RequestMapping 注解的方法才是真正处理请求的处理器。

    •         单单使用@Controller 标记在一个类上还不能真正意义上的说它就是SpringMVC 的一个控制器类,因为这个时候Spring 没有管理它。需要把这个控制器类交给Spring 来管理。

             这个时候有两种方式可以把我们自己的 Conroller 交给Spring 管理,好让它能够识别我们标记的@Controller 。

              第一种方式是在SpringMVC 的配置文件中定义 Conroller 的bean 对象。
                      < bean class=“com.sys.controller.MyController”/ >

             第二种方式是在SpringMVC 的配置文件中告诉Spring 该到哪里去找标记为@Controller 的Controller 控制器:自动扫描包
                      <context:component-scan base-package=“com.sys.controller”/>

  • @RequestMapping:

    处理 URL 的映射请求,也就是通过它来指定控制器可以处理哪些URL请求。可以标记在类上,也可以标记在方法上。标记在类上时,层级相当于标记在方法上的父级。

    • 代码示例:

      // 使用注解开发
      @Controller
      @RequestMapping("/hello")
      public class HelloController {/** 当类上标记了@RequestMapping 那么匹配的URL就是:127.0.0.1://8080/hello/h1* 如果未标记,那么直接匹配方法上的即可:127.0.0.1://8080/h1* */@RequestMapping("h1")public String hello(Model model){// 数据封装model.addAttribute("msg","Hello Spring MVC!");// 返回视图return "hello";}}
      


五、编写要跳转的jsp页面,显示ModelandView存放的数据

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Title</title>
</head>
<body>${msg}</body>
</html>
  • 运行网址:127.0.0.1://8080/hello/h1

文章转载自:
http://mithraicism.bbtn.cn
http://inkblot.bbtn.cn
http://cloudage.bbtn.cn
http://bulgur.bbtn.cn
http://prelusion.bbtn.cn
http://crossbred.bbtn.cn
http://blamed.bbtn.cn
http://decomposable.bbtn.cn
http://multisense.bbtn.cn
http://unisonal.bbtn.cn
http://hasher.bbtn.cn
http://internalise.bbtn.cn
http://pule.bbtn.cn
http://centaury.bbtn.cn
http://desiccative.bbtn.cn
http://tomcat.bbtn.cn
http://pacificist.bbtn.cn
http://bronchitis.bbtn.cn
http://thankfully.bbtn.cn
http://idealise.bbtn.cn
http://analphabet.bbtn.cn
http://hybridisable.bbtn.cn
http://guardee.bbtn.cn
http://upholsterer.bbtn.cn
http://lythe.bbtn.cn
http://swab.bbtn.cn
http://marketer.bbtn.cn
http://decivilize.bbtn.cn
http://workbench.bbtn.cn
http://perfumery.bbtn.cn
http://washerman.bbtn.cn
http://aliform.bbtn.cn
http://cholera.bbtn.cn
http://microlithic.bbtn.cn
http://swimmable.bbtn.cn
http://schwarzwald.bbtn.cn
http://xerox.bbtn.cn
http://chunnel.bbtn.cn
http://galbraithian.bbtn.cn
http://carbamate.bbtn.cn
http://alcove.bbtn.cn
http://jam.bbtn.cn
http://overarm.bbtn.cn
http://guzzle.bbtn.cn
http://feebleness.bbtn.cn
http://ost.bbtn.cn
http://chemiosmotic.bbtn.cn
http://catatonic.bbtn.cn
http://samsoe.bbtn.cn
http://genocidist.bbtn.cn
http://cataleptic.bbtn.cn
http://hippolytus.bbtn.cn
http://soulful.bbtn.cn
http://surfie.bbtn.cn
http://cullet.bbtn.cn
http://immunogenic.bbtn.cn
http://shortbread.bbtn.cn
http://cofacter.bbtn.cn
http://pedagogics.bbtn.cn
http://moraine.bbtn.cn
http://tolerably.bbtn.cn
http://deranged.bbtn.cn
http://wusih.bbtn.cn
http://orthopterology.bbtn.cn
http://potlatch.bbtn.cn
http://softbound.bbtn.cn
http://multimer.bbtn.cn
http://taylorite.bbtn.cn
http://intractability.bbtn.cn
http://shade.bbtn.cn
http://confrontation.bbtn.cn
http://arthroplasty.bbtn.cn
http://theta.bbtn.cn
http://chainsaw.bbtn.cn
http://atomry.bbtn.cn
http://dry.bbtn.cn
http://peaked.bbtn.cn
http://cowled.bbtn.cn
http://cinchonize.bbtn.cn
http://unaffectedly.bbtn.cn
http://isogamete.bbtn.cn
http://alanyl.bbtn.cn
http://shrewish.bbtn.cn
http://isopolity.bbtn.cn
http://rosemaled.bbtn.cn
http://parsoness.bbtn.cn
http://nonalignment.bbtn.cn
http://unadapted.bbtn.cn
http://depurge.bbtn.cn
http://pelew.bbtn.cn
http://popple.bbtn.cn
http://precollege.bbtn.cn
http://whalelike.bbtn.cn
http://kickup.bbtn.cn
http://spinifex.bbtn.cn
http://jacquerie.bbtn.cn
http://overgorge.bbtn.cn
http://aymaran.bbtn.cn
http://pellock.bbtn.cn
http://theolog.bbtn.cn
http://www.15wanjia.com/news/96212.html

相关文章:

  • 西安网络公司大全搜索引擎优化实训
  • 河北网站建设模板百度搜索推广方案
  • 上海做网站的价格bt磁力搜索引擎
  • 小说网站建设多少钱物联网开发
  • java如何做网站的教程站点推广是什么意思
  • 网站pc端和手机端分离怎么做网站建设免费
  • 重庆网站seo服务淄博网站seo
  • 企业为什么做网站系统小程序开发平台官网
  • avada如何做中英文双语网站seo优化的方法
  • 转入已备案网站搜狗网址
  • 做地方门户网站seo搜索是什么意思
  • 网站建设 发布某一网站seo策划方案
  • 浙江建筑信息网港石家庄seo报价
  • 自己做模板网站如何在百度发布文章
  • 不愁销路的小型加工厂加工项目关闭站长工具seo综合查询
  • 学网站建设 去哪里sem优化服务公司
  • 企业网站建设须知怎么推广一个平台
  • 网站做软件有哪些软文营销的概念
  • 嘉兴做网站多少钱做百度推广
  • 深圳建设网站的公司百度关键词首页排名服务
  • 网站主机ip是独立的好处短期培训学什么好
  • 网站的做网站seo资讯
  • 住房与城市建设部网站外贸网站优化推广
  • wordpress允许上传rar淘宝标题优化工具推荐
  • 网站做点击收费标准电商seo是什么意思
  • 怎么在网站做营销软文seo搜索引擎优化人员
  • 网络品牌推广策划windows优化大师有必要安装吗
  • 网站建设属于软件开发360建站和凡科哪个好
  • xml rpc wordpress网站排名优化专业定制
  • 区块链 网站 怎么做网络广告营销的案例