我有一个domainPrice设置为BigDecimal数据类型的域类.现在我正在尝试创建一个比较价格的方法,但似乎我不能在BigDecimal数据类型中有比较运算符.我是否必须更改数据类型或是否有其他方法?
我试图在春天将列表转换为页面.我用它转换了它
new PageImpl(users,pageable,users.size());
但现在我有排序和分页本身的问题.当我尝试传递大小和页面时,分页不起作用.
这是我正在使用的代码.
我的控制器
public ResponseEntity<User> getUsersByProgramId(
@RequestParam(name = "programId", required = true) Integer programId Pageable pageable) {
List<User> users = userService.findAllByProgramId(programId);
Page<User> pages = new PageImpl<User>(users, pageable, users.size());
return new ResponseEntity<>(pages, HttpStatus.OK);
}
Run Code Online (Sandbox Code Playgroud)
这是我的用户回购
public interface UserRepo extends JpaRepository<User, Integer>{
public List<User> findAllByProgramId(Integer programId);
Run Code Online (Sandbox Code Playgroud)
这是我的服务
public List<User> findAllByProgramId(Integer programId);
Run Code Online (Sandbox Code Playgroud) 我有一张桌子上有学生的详细信息.这些字段是只读字段,可以在单击编辑按钮时进行编辑.但是我在单击编辑按钮时一次选择该行的所有输入字段时遇到问题.
这是我的HTML代码
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Checklist</th>
<th>Id</th>
<th>Student Name</th>
<th>Address</th>
<th>Phone</th>
<th>Class</th>
<th colspan="2">Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="checkbox" id="editCheck" class="btn1" />
<input type="checkbox" id="deleteCheck" />
</td>
<td>1</td>
<td><input type="text" class="form-control item" readonly="readonly" /></td>
<td><input type="text" class="form-control item" readonly="readonly" /></td>
<td><input type="text" class="form-control item" readonly="readonly" /></td>
<td>12</td>
<td><button type="button" class="btn btn-info btn-xs" id="btn1">Edit</button></td>
<td><button type="button" class="btn btn-danger btn-xs" id="dbtn1">Delete</button></td>
</tr>
<tr>
<td>
<input type="checkbox" id="editCheck" class="btn2" />
<input type="checkbox" …Run Code Online (Sandbox Code Playgroud) 我在UserController.php中不断收到此错误'Class'App\Http\Controllers\Mail'not found'错误
public function store(CreateUserRequest $request)
{
$result = DB::table('clients')->select('client_code','name','email')
->where('client_code','=',$request->code)
->where('email','=',$request->email)
->first();
if($result){
$tmp_pass = str_random(10);
$user = User::create([
'username' => $result->name,
'email' => $request->email,
'password' => $tmp_pass,
'tmp_pass' => '',
'active' => 0,
'client_code' => $request->code
]);
if($user){
Mail::send('emails.verify',array('username' => $result->name, 'tmp_pass' => $tmp_pass), function($message) use ($user){
$message->to($user->email, $user->username)
->subject('Verify your Account');
});
return Redirect::to('/')
->with('message', 'Thanks for signing up! Please check your email.');
}
else{
return Redirect::to('/')
->with('message', 'Something went wrong');
}
}
else{
Session::flash('message', "Invalid code …Run Code Online (Sandbox Code Playgroud) 我想DbContext在我的ActionFilter中间件中使用a .可能吗?
public class VerifyProfile : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
using (var context = new SamuraiDbContext())
{
var user = filterContext.HttpContext.User.Identity.Name;
if (context.Profiles.SingleOrDefaultAsync(p => p.IdentityName == user).Result == null)
{
filterContext.Result = new RedirectResult("~/admin/setup");
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是这段代码using (var context = new SamuraiDbContext())需要传递选项.我应该再次通过DbContextOptionsBuilder()这里还是有其他办法吗?
我想[VerifyProfile]在我的控制器方法中有属性.有可能吗?
c# asp.net-core-mvc asp.net-core asp.net-core-2.0 ef-core-2.0
我想只从这个字符串中获取链接:
"<p><a href=\"https://www.youtube.com/watch?v=i2yscjyIBsk\">https://www.youtube.com/watch?v=i2yscjyIBsk</a></p>\n"
Run Code Online (Sandbox Code Playgroud)
我希望输出为 https://www.youtube.com/watch?v=i2yscjyIBsk
那么,我怎么能实现它呢?
我试过了:
func matches(for regex: String, in text: String) -> [String] {
do {
let regex = try NSRegularExpression(pattern: regex)
let nsString = text as NSString
????let results = regex.matches(in: text, range: NSRange(location: 0, length: nsString.length))
????return results.map { nsString.substring(with: $0.range)}
} catch let error {????
}
Run Code Online (Sandbox Code Playgroud)
并尝试了这个正则表达式: "<a[^>]+href=\"(.*?)\"[^>]*>.*?</a>"
但我仍然无法弄明白.
java ×2
spring ×2
asp.net-core ×1
bigdecimal ×1
c# ×1
ef-core-2.0 ×1
email ×1
html ×1
javascript ×1
jquery ×1
laravel ×1
list ×1
pagination ×1
php ×1
regex ×1
spring-data ×1
swift ×1