2018最新android框架,2018Android手把手打造一个万能框架完成电商App开发实战全套完整版...

package com.sv.controller;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.RequestMapping;

/**

* 页面展示

* @author jixh

*

*/

@Controller

public class PageController {

/**

* 展示首页

* @return

*/

@RequestMapping(value="/")

public String indexShow() {

return "index";

}

/**

* 展示其他页面,每一个页面请求都要写一个对应的页面返回处理,这样太过麻烦,进行简化

* 方法:正如所见,将请求的URL和处理函数返回的URL写成一样的,这样一来就可以使用

* Restfaull的URL模板映射,直接将请求的URL作为返回的URL,    如此就可公用了

* 如果参数名称和表达式名称不一致时,加参数(@PathVariable(value="page") String page3)

*

*/

@RequestMapping(value="/{page}")

public String pageShow(@PathVariable String page) {

return page;

}

}

package com.huawei.myconfig;

import org.springframework.context.annotation.Configuration;

import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration//标志当前类在启动的时候会被加载

public class MyConfiguration implements WebMvcConfigurer {

//视图控制器配置

@Override

public void addViewControllers(ViewControllerRegistry registry) {

//urlPath:浏览器输入的地址  viewName:该地址跳转到的页面,不加templates文件夹和.html

//registry.addViewController("/left").setViewName("left");错误的写法

registry.addViewController("/login").setViewName("left.html");

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值