请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

调试的时候遇到后台接收不到前台参数的问题,大家帮我看看,多谢

新增店铺的时候,通过传递图片流,数据流,以及验证码全部封装到一个对象formData里进行传输,后台通过request.getParamter(key)获取不到,有遇到过该问题的,还望告知,谢谢图片描述

图片描述

正在回答 回答被采纳积分+3

插入代码

2回答

翔仔 2019-03-28 00:42:56

看看chrome开发者里面,同学传入的请求contenttype是多少?

同时,同学可以把maven repository下面的jar全部清空,之后重新update maven project,rebuild project,再clean tomcat试试

同时请检查import的request是否是

import javax.servlet.http.HttpServletRequest;

这些都要排查哈

1 回复 有任何疑惑可以回复我~
  • 都是啊,但是就是接受不到参数
    回复 有任何疑惑可以回复我~ 2019-03-28 09:34:01
  • 同学你把项目发送到course_o2o@163.com,我最近比较忙,这几天有空就帮同学看看,同学期间也可以按照视频的重新弄一遍,肯定还是哪里配置有问题。
    回复 有任何疑惑可以回复我~ 2019-03-29 00:38:57
翔仔 2019-03-27 00:55:31

同学好,可能是由于spring-web.xml配置有问题导致,可以直接复制粘贴我的,之后没问题再看看差别在哪里

spring-web.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?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/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-3.2.xsd">
    <!-- 配置SpringMVC -->
    <!-- 1.开启SpringMVC注解模式 -->
    <mvc:annotation-driven />
 
    <!-- 2.静态资源默认servlet配置 (1)加入对静态资源的处理:js,gif,png (2)允许使用"/"做整体映射 -->
    <mvc:resources mapping="/resources/**" location="/resources/" />
    <mvc:default-servlet-handler />
 
    <!-- 3.定义视图解析器 -->
    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/html/"></property>
        <property name="suffix" value=".html"></property>
    </bean>
    <!-- 文件上传解析器 -->
    <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="defaultEncoding" value="utf-8"></property>
        <!-- 1024 * 1024 * 20 = 20M -->
        <property name="maxUploadSize" value="20971520"></property>
        <property name="maxInMemorySize" value="20971520"></property>
    </bean>
 
    <!-- 4.扫描web相关的bean -->
    <context:component-scan base-package="com.imooc.o2o.web" />
</beans>

如果还是不行,建议先把shopImage注释掉,先不传入后台,看看能否获取到shopStr这个值。

如果还是不行,请检查import的request是否是

import javax.servlet.http.HttpServletRequest;

总之,还需要一步步排查

如果还是不行,看看chrome开发者里面,同学传入的请求contenttype是多少

1 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号