小编Shi*_*abu的帖子

使用带有引导程序的Fieldset Legend

我正在使用Bootstrap作为我的JSP页面.

我想使用<fieldset><legend>我的形式.这是我的代码.

<fieldset class="scheduler-border">
    <legend class="scheduler-border">Start Time</legend>
    <div class="control-group">
        <label class="control-label input-label" for="startTime">Start :</label>
        <div class="controls bootstrap-timepicker">
            <input type="text" class="datetime" id="startTime" name="startTime" placeholder="Start Time" />
            <i class="icon-time"></i>
        </div>
    </div>
</fieldset>
Run Code Online (Sandbox Code Playgroud)

CSS是

fieldset.scheduler-border {
    border: 1px groove #ddd !important;
    padding: 0 1.4em 1.4em 1.4em !important;
    margin: 0 0 1.5em 0 !important;
    -webkit-box-shadow:  0px 0px 0px 0px #000;
            box-shadow:  0px 0px 0px 0px #000;
}

legend.scheduler-border {
    font-size: 1.2em !important;
    font-weight: bold !important;
    text-align: left !important; …
Run Code Online (Sandbox Code Playgroud)

html css forms twitter-bootstrap

160
推荐指数
6
解决办法
37万
查看次数

复选框值始终为"打开"

这是我的复选框

HTML

<label class="checkbox">
    <input id="eu_want_team" name="eu_want_team" type="checkbox">
</label>
Run Code Online (Sandbox Code Playgroud)

JQuery的

var eu_want_team = $('#eu_want_team').val();
alert(eu_want_team);
Run Code Online (Sandbox Code Playgroud)

它总是显示ON,是否检查.问题是什么?

html javascript checkbox jquery dom

60
推荐指数
2
解决办法
3万
查看次数

添加类后,jQuery click事件无法正常工作

在我的JSP页面中,我添加了一些链接:

<a class="applicationdata" href="#" id="1">Organization Data</a>
<a class="applicationdata" href="#" id="2">Business Units</a>
<a class="applicationdata" href="#" id="6">Applications</a>
<a class="applicationdata" href="#" id="15">Data Entity</a>
Run Code Online (Sandbox Code Playgroud)

它有一个为click事件注册的jQuery函数:

$("a.applicationdata").click(function() {
    var appid = $(this).attr("id");
    $('#gentab a').addClass("tabclick");
    $('#gentab a').attr('href', '#datacollector');
});
Run Code Online (Sandbox Code Playgroud)

这将增加一类,tabclick<a>这里面<li>id="gentab".它工作正常.这是我的代码<li>:

<li id="applndata"><a class="tabclick" href="#appdata" target="main">Application Data</a></li>
<li id="gentab"><a href="#datacollector" target="main">General</a></li>
Run Code Online (Sandbox Code Playgroud)

现在我有这些链接的jQuery点击处理程序

$("a.tabclick").click(function() {
    var liId = $(this).parent("li").attr("id");
    alert(liId);        
});
Run Code Online (Sandbox Code Playgroud)

对于第一个链接,它工作正常.这是警告<li>id.但是对于第二个<li>,class="tabclick"第一个jQuery添加的地方不起作用.

我试过了$("a.tabclick").live("click", function(),但是第一个链接点击事件也没有用.

jquery

51
推荐指数
4
解决办法
11万
查看次数

Spring MVC - AngularJS - 文件上传 - org.apache.commons.fileupload.FileUploadException

我有一个Java Spring MVC Web应用程序作为服务器.而基于AngularJS的应用程序作为客户端.

在AngularJS中,我必须上传文件并发送到服务器.

这是我的HTML

<form ng-submit="uploadFile()" class="form-horizontal" enctype="multipart/form-data">
   <input type="file" name="file" ng-model="document.fileInput" id="file" onchange="angular.element(this).scope().setTitle(this)" />
   <input type="text" class="col-sm-4" ng-model="document.title" id="title" />
   <button class="btn btn-primary" type="submit">
         Submit
    </button>
</form>
Run Code Online (Sandbox Code Playgroud)

这是我的UploadController.js

'use strict';

var mainApp=angular.module('mainApp', ['ngCookies']);

mainApp.controller('FileUploadController', function($scope, $http) {

    $scope.document = {};

        $scope.setTitle = function(fileInput) {

        var file=fileInput.value;
        var filename = file.replace(/^.*[\\\/]/, '');
        var title = filename.substr(0, filename.lastIndexOf('.'));
        $("#title").val(title);
        $("#title").focus();
        $scope.document.title=title;
    };

        $scope.uploadFile=function(){
             var formData=new FormData();
         formData.append("file",file.files[0]);
                   $http({
                  method: 'POST',
                  url: '/serverApp/rest/newDocument',
                  headers: { 'Content-Type': 'multipart/form-data'},
                  data: …
Run Code Online (Sandbox Code Playgroud)

java spring file-upload spring-mvc angularjs

18
推荐指数
4
解决办法
5万
查看次数

AngularJS使用全局变量更改<body>类

我刚刚创建了一个angularJS应用程序.

这是我的index.html

<html ng-app="MyApp">
  <head>
    <!-- CSS files import -->
  </head>
  <body class="{{bodylayout}}">
    <div ng-view></div>
  </body>
  <--! JS imports 
   aungular.js
   app.js
   login.js
   register.js
   -->
</html>
Run Code Online (Sandbox Code Playgroud)

app.js

'use strict';
//Define Routing for app
angular.module('myApp', []).config(['$routeProvider', '$locationProvider',
  function($routeProvider,$locationProvider) {
    $routeProvider
    .when('/login', {
        templateUrl: 'login.html',
        controller: 'LoginController'
    })
    .when('/register', {
        templateUrl: 'register.html',
        controller: 'RegisterController'
      })
    .when('/forgotPassword', {
        templateUrl: 'forgotpassword.html',
        controller: 'forgotController'
      })
   .when('/home', {
       templateUrl: 'views/home.html',
    })
    .otherwise({
       redirectTo: '/login'
    });
//    $locationProvider.html5Mode(true); //Remove the '#' from URL.
}]);
Run Code Online (Sandbox Code Playgroud)

我有login.html,register.html和forgetpassword.html,home.html.每个人都在单独的文件中有独立的控制器.login.js,register.js,forgot.js,home.js.

login.js

'use …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery global-variables angularjs

17
推荐指数
3
解决办法
3万
查看次数

JsonMappingException:无法从JSON String实例化类型[simple type,abcCompany]的值; 没有单字符串构造函数/工厂方法

我刚刚在我现有的Spring + BlazeDS + Hibernate服务器上添加了一个REST api,当数据被检索并序列化为JSON时,一切似乎都有效,但是当我尝试将POST数据反序列化为POJO时,我得到了一个例外.

我的印象是弹簧注释和类路径中杰克逊罐子的存在将是所有需要的,至少它是我的列表,获取,删除具有简单参数的方法.

org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class com.twoh.dto.Company] from JSON String; no single-String constructor/factory method
Run Code Online (Sandbox Code Playgroud)

这是被调用的方法:

public abstract class BaseEntityService<T extends BaseEntity> implements IBaseEntityService<T> {

private IBaseEntityDAO<T> DAO;

@Autowired
private ValidationResultHelper validationResultHelper;

public void setDAO(IBaseEntityDAO<T> DAO) {
    this.DAO = DAO;
}

...
@Secured("ROLE_USER")
@RequestMapping(value="/create", method=RequestMethod.POST)
public @ResponseBody ValidationResult create(@RequestBody T entity) {
    ValidationResult result = null;
    try {
        result = DAO.persistEntity(entity);
    } catch(JDBCException e) {
        result = ExceptionHelper.getValidationResult(e);
    } catch(DataIntegrityViolationException …
Run Code Online (Sandbox Code Playgroud)

rest spring json jackson

12
推荐指数
1
解决办法
8万
查看次数

AngularJS - html5Mode - 无法GET /登录

您已经用自耕农,咕噜声和凉亭创建了一个angularJS应用程序.我为应用程序启用了html5Mode.它的工作.但是,当我刷新页面(localhost:9000/login)时,它说

Cannot GET /login //or any url I type or refresh
Run Code Online (Sandbox Code Playgroud)

这是应用程序结构

MainApp
|
|__app
|  |
|  |__bower_components
|  |
|  |__scripts
|  | |
|  | |__ app.js
|  | |
|  | |__contollers -- login.js, home.js, register.js
|  | |
|  | |__service -- js files
|  | |
|  | |__styles -- CSS files
|  | |
|  | |__views -- main.html, login.html, register.html,home.html
|  |
|  |__ index.html
|
|__ node_modules
|
|__ bower.json, Gruntfile.js, …
Run Code Online (Sandbox Code Playgroud)

html5 angularjs gruntjs

10
推荐指数
1
解决办法
1万
查看次数

将MultipartFile转换为java.io.File而不复制到本地计算机

我有一个Java Spring MVC Web应用程序.从客户端到AngularJS,我上传文件并将其作为webservice发布到Controller.

在我的控制器中,我将其作为MultipartFile获取,我可以将其复制到本地计算机.

但我想将文件上传到Amazone S3存储桶.所以我必须将其转换为java.io.File.现在我正在做的是,我将它复制到本地机器,然后使用jets3t上传到S3 .

这是我在控制器中转换的方式

MultipartHttpServletRequest mRequest=(MultipartHttpServletRequest)request;

Iterator<String> itr=mRequest.getFileNames();
        while(itr.hasNext()){
            MultipartFile mFile=mRequest.getFile(itr.next());
            String fileName=mFile.getOriginalFilename();

            fileLoc="/home/mydocs/my-uploads/"+date+"_"+fileName; //date is String form of current date.
Run Code Online (Sandbox Code Playgroud)

然后我使用SpringFramework的FIleCopyUtils

File newFile = new File(fileLoc);

                  // if the directory does not exist, create it
                  if (!newFile.getParentFile().exists()) {
                    newFile.getParentFile().mkdirs();  
                  }
                FileCopyUtils.copy(mFile.getBytes(), newFile);
Run Code Online (Sandbox Code Playgroud)

因此它将在本地计算机中创建一个新文件.那个文件我在S3上面了

S3Object fileObject = new S3Object(newFile);

s3Service.putObject("myBucket", fileObject);
Run Code Online (Sandbox Code Playgroud)

它在我的本地系统中创建文件.我不想创造.

如果不在本地系统中创建文件,如何将MultipartFIle转换为java.io.File

java file-io spring-mvc multipart

10
推荐指数
2
解决办法
3万
查看次数

AngularJS表单提交不与JQuery验证一起使用

我有一个AngularJS应用程序.我有一个注册页面.

看起来像这样

register.html

<form id="userRegistration" ng-submit="registerUser()" >
<fieldset>
    <label class="block clearfix">
        <span class="block">
            <input type="text" class="form-control" id="Username" ng-model="user.username" name="username" placeholder="Username" required="required" />
        </span>
    </label>

    <label class="block clearfix">
        <span class="block">
            <input type="password" class="form-control" id="password" ng-model="user.password" name="password" placeholder="Password" required="required" />
        </span>
    </label>

    <label class="block clearfix">
        <span class="block">
            <input type="email" class="form-control" id="email" ng-model="user.email" name="emailId" placeholder="Email" required="required" />
        </span>
    </label>
    <div class="clearfix">
        <button type="reset" class="width-48 pull-left btn btn-sm">
            Reset
        </button>

        <button type="submit" class="width-48 pull-right btn btn-sm btn-success">
            Register
        </button>
    </div>
</fieldset>
Run Code Online (Sandbox Code Playgroud)

我正在使用这个wraspbootstrap主题.它有表格验证.我正在使用的验证.我已经在页面中给出了我的规则. …

javascript forms validation jquery angularjs

3
推荐指数
1
解决办法
9454
查看次数

bitronix-无法找到当前的JTA事务

嗨,我有一个使用spring和hibernate的Java Web应用程序.

我有一个名为Role的模型类.对于所有模型类,都有常见的GenericDao.java

public interface GenericDao<T>{
    public void insert(T transientInstance);      
    public T findById(Class<?> clazz, Serializable id); 
}
Run Code Online (Sandbox Code Playgroud)

GenericHibernateDao.java

@Repository
public class GenericHibernateDao<T extends Serializable>
implements GenericDao<T>{

    @Resource
    protected SessionFactory sessionFactory;

    @Override
    public void insert(T transientInstance) {
        sessionFactory.getCurrentSession().persist(transientInstance);
    }
        @SuppressWarnings("unchecked")
    @Override
    public T findById(Class<?> clazz, Serializable id) {
        return (T) sessionFactory.getCurrentSession().get(clazz, id);
        }
}
Run Code Online (Sandbox Code Playgroud)

RoleService.java

public interface RoleService {
    public void insert(Role role);
    public Role findById(Integer id);
}
Run Code Online (Sandbox Code Playgroud)

并且有它的实现RoleServiceImpl.java

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired …
Run Code Online (Sandbox Code Playgroud)

java spring hibernate spring-mvc bitronix

3
推荐指数
1
解决办法
7517
查看次数