springmvcget中文乱码_springmvc接收url中文参数乱码

1.今天在做一个例子的时候,发现后台不能正确接收中文的url参数,试了各种解决办法都不可以。

以下是代码:

Controller:

package com.springapp.mvc;

import org.springframework.stereotype.Controller;

import org.springframework.ui.ModelMap;

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

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

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

@Controller

@RequestMapping("/")

public class HelloController {

@RequestMapping(method = RequestMethod.GET)

public String printWelcome(ModelMap model) {

model.addAttribute("message", "Hello world IDEA!");

model.put("content","This is my first springmvc web");

return "index";

}

@RequestMapping(value = "/page/{name}/{age}",method = RequestMethod.GET)

public String getName(ModelMap modelMap, @PathVariable("name") String name, @PathVariable("age") int age) {

modelMap.addAttribute("name",name);

modelMap.addAttribute("age",age);

return "name";

}

}

name.jsp

名字:${name}

年龄:${age}

web.xml

xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

Spring MVC Application

mvc-dispatcher

org.springframework.web.servlet.DispatcherServlet

1

mvc-dispatcher

/

characterEncodingFilter

org.springframework.web.filter.CharacterEncodingFilter

encoding

UTF-8

forceEncoding

true

characterEncodingFilter

/*

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值