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