2 u010345450 u010345450 于 2016.04.15 17:35 提问

jersey框架下上传form表单出错

前端form

 <form id="picForm" action="/intelligentStage-system-manage/rest/admin/addimage" method="post" enctype="multipart/form-data">  
            <label style="margin-top: 30px;">用户名:</label> 
            <input type="text" id="adminName" name="adminName" />   <br>
            <img src="" id="showPhoto" style="float: right;width: 100px;height: 100px;margin-right: 40px;" />
            <label>密码:</label> 
            <input type="password" id="password" name="password" /> <br>
            <label>确认密码:</label> 
            <input type="password" id="confirm" />  <br>
            <label>姓名:</label> 
            <input type="text" id="name" name="name" /> <br>
            <label>性别:</label> 
            <select id="sex" name="sex" style="width: 100px;height: 30px;">
                              <option value="1">男</option>
                              <option value="2">女</option>
             </select>  <br>

            <input id="photo" name="photo"   type="file" style="float: right;margin-right: 60px;" value="添加照片"/>
            <label>生日:</label> 
            <input type="text" id="birth" name="birth" onClick="WdatePicker()"  clientidmode="Static" /> <br>
            <label>联系方式:</label> 
            <input type="text" id="contact" name="contact" /><br>
            <label>入职时间:</label> 
            <input type="text" id="entryTime" name="entryTime" onClick="WdatePicker()"  clientidmode="Static" />    <br>
            <label>微信:</label> 
            <input type="text" id="wechat" name="wechat" /> <br>
            <label>公司名称:</label> 
            <select id="company" name="company" style="width: 100px;height: 30px;">
                              <option value="0">不限</option>
             </select>  <br>
            <label>备注:</label> 
            <input type="text" id="content" name="content" />   <br>

             <input type="submit" value="上传" /> 
            </form>

后台接收
@POST
@Path("/addimage")
@Produces(MediaType.TEXT_PLAIN)
@Consumes("multipart/form-data")
public String addimage(FormDataMultiPart formDataMultiPart) throws UnsupportedEncodingException{
return null;
}

但是前端会报错
POST http://192.168.223.31:8080/intelligentStage-system-manage/rest/admin/addimage 415 (Unsupported Media Type)
请大神解释一下,谢谢

1个回答

devmiao
devmiao   Ds   Rxr 2016.04.15 23:45
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!