老师请检查!,有一个JSP的页面显示乱码的问题
用html格式弄出来是中文的
但用jsp弄出来是乱码的,格式都设置了,不知道是哪里的问题!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测量体重</title>
</head>
<body>
<form action="/cacult" method="post">
<fieldset>
<legend>计算BMI身体指数</legend>
身高:<input name="h" >cm
体重:<input name="w">kg
<input type="submit" value="提交测试">
</fieldset>
</form>
</body>
</html>
package springmvc.mvc1;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class Work1 {
@PostMapping("/cacult")
@ResponseBody
public String postMapping(Double h, Integer w){
h*=0.01;
Double ok= w/(h*h);
if (ok>25){
return "该减肥了,胖猪!";
}else if (ok<19){
return "多吃点!虾子!";
}else {
return "正常";
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mv="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/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--
context:component-scan 标签作用
在Spring IOC初始化过程中,自动创建并管理com.imooc.springmvc及子包中
拥有以下注解的对象.
@Repository
@Service
@Controller
@Component
-->
<context:component-scan base-package="springmvc"></context:component-scan>
<!--启用Spring MVC的注解开发模式-->
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=utf-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!-- 将图片/JS/CSS等静态资源排除在外,可提高执行效率 -->
<mvc:default-servlet-handler/>
</beans>
49
收起
正在回答 回答被采纳积分+1
1回答
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星