<!-- 配置多媒体解析器 -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="UTF-8"></property>
<!-- 设定文件上传的最大值 5MB,5*1024*1024 -->
<property name="maxUploadSize" value="5242880"></property>
</bean>
//控制层
app.controller('contentController' ,function($scope,$controller ,contentService,u
ploadService){
<script type="text/javascript" src="../js/service/uploadService.js"> </script>
//上传广告图
$scope.uploadFile=function(){
uploadService.uploadFile().success(
function(response){
if(response.success){
$scope.entity.pic=response.message;
}else{
alert("上传失败!");
}
}
).error(
function(){
alert("上传出错!");
}
);
}
<tr>
<td>图片</td>
<td>
<input type="file" id="file">
<button ng-click="uploadFile()">上传</button>
<img alt="" src="{{entity.pic}}" height="100px" width="200px">
</td>
</tr>
<img alt="" src="{{entity.pic}}" height="50px" width="100px">
//加载广告分类列表
$scope.findContentCategoryList=function(){
contentCategoryService.findAll().success(
function(response){
$scope.contentCategoryList=response;
}
);
}
<body
class="hold-transition skin-red sidebar-mini"
ng-app="pinyougou"
ng-controller="contentController" ng-init="findContentCategoryList()">
<select class="form-control" ng-model="entity.categoryId" ng-options="item.id as
item.name for item in contentCategoryList"></select>
<input
type="checkbox"
ng-model="entity.status"
ng-true-value="1"
ng-false-value="0">
$scope.status=["无效","有效"];
{{status[entity.status]}}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |