我正在尝试使用 react-js-pagination 在我的 Web 应用程序中创建分页。分页显示在网页中,但我想根据页码更改 url 内的页面参数,例如&page=4。我试着用
this.props.history.push(`${window.location.search}&page=${pageNumber}`)
Run Code Online (Sandbox Code Playgroud)
但&page=4每次我点击分页链接时都会附加。我知道这种更新网址的错误方式。如何根据 url 中的 pageNumber 仅更新页面参数?
handlePageChange = (pageNumber) => {
this.setState({activePage: pageNumber});
this.props.history.push(`${window.location.search}&page=${pageNumber}`)
}
<Pagination
activePage={this.state.activePage}
itemsCountPerPage={10}
totalItemsCount={100}
onChange={this.handlePageChange}
/>
Run Code Online (Sandbox Code Playgroud) 我正在尝试将Elasticsearch添加到我的项目中。我已经将必要的依赖项添加到了pom.xml文件中。当我运行服务器时,出现此错误:
Run Code Online (Sandbox Code Playgroud)java.lang.IllegalStateException: Failed to introspect Class [net.kzn.shoppingbackend.config.HibernateConfig] from ClassLoader [ParallelWebappClassLoader
请帮我解决这个问题。
我也试图在eclipse中找到elasticsearch.yml文件来配置节点,但是没有这样的文件。在哪里可以找到elasticsearch.yml文件。
HibernateConfig.java
package net.kzn.shoppingbackend.config;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;
import javax.sql.DataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.orm.hibernate5.HibernateTransactionManager;
import org.springframework.orm.hibernate5.LocalSessionFactoryBuilder;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableElasticsearchRepositories(basePackages = "net.kzn.shoppingbackend")
@ComponentScan(basePackages = { "net.kzn.shoppingbackend" })
@EnableTransactionManagement
public class HibernateConfig {
// change the below based on the DBMS you …Run Code Online (Sandbox Code Playgroud) 我创建了 angular 和 spring boot 应用程序,我想将它部署在 tomcat 服务器上。为此,我在 spring boot 项目中复制了 angular 项目,并提供了 pom.xml 来创建 war 文件。之后我在tomcat上部署了war文件并启动了。请告诉我是什么
控制台错误
org.springframework.security.web.session.SessionManagementFilter@af8f6da, org.springframework.security.web.access.ExceptionTranslationFilter@7551f180, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@67dc6d01]
2020-10-14 19:17:57.066 INFO 5176 --- [ost-startStop-1] o.s.d.r.w.RepositoryRestHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3472387b: startup date [Wed Oct 14 19:17:26 IST 2020]; root of context hierarchy
2020-10-14 19:17:57.071 INFO 5176 --- [ost-startStop-1] o.s.d.r.w.RepositoryRestHandlerAdapter : Detected @ModelAttribute methods in globalController
2020-10-14 19:17:57.100 INFO 5176 --- [ost-startStop-1] o.s.d.r.w.RepositoryRestHandlerMapping : …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的应用程序中使用react-bootstrap-typeahead。我正在使用此处显示的示例https://ericgio.github.io/react-bootstrap-typeahead/。这是组件
<Typeahead
labelKey={(option) => `${option.firstName} ${option.lastName}`}
options={[
{firstName: 'Art', lastName: 'Blakey'},
{firstName: 'John', lastName: 'Coltrane'},
{firstName: 'Miles', lastName: 'Davis'},
{firstName: 'Herbie', lastName: 'Hancock'},
{firstName: 'Charlie', lastName: 'Parker'},
{firstName: 'Tony', lastName: 'Williams'},
]}
onInputChange={this.handleInputChange}
onKeyDown={ this._handleChange}
value={this.state.value}
placeholder="Who's the coolest cat?"
/>
Run Code Online (Sandbox Code Playgroud)
这是句柄更改函数
_handleChange = (e) => {
console.log("value",e.target.value)
}
Run Code Online (Sandbox Code Playgroud)
当我尝试控制台记录选择的值时,它显示以前选择的值。我想获取当前选择的值。我怎样才能获得当前选择的值。
我正在尝试使用 axios get request 将名称数组传递给 spring 控制器。如果我尝试在 params 中传递单个值,它工作正常,但如果在 params 中传递数组,那么我会收到错误“CORS 标头‘Access-Control-Allow-Origin ' 丢失的”。我试过这个
这是网址
http://localhost:8080/onlineshopping/view/category/products?name[]=Alex&name[]=john
Run Code Online (Sandbox Code Playgroud)
任务动作.js
var request = {
params: {
name : JSON.parse(localStorage.getItem('name'))
}
}
const res = await axios.get(`http://localhost:8080/onlineshopping/view/category/products`,request);
dispatch({
type: GET_CATEGORY_PRODUCTS,
payload: res.data
});
};
Run Code Online (Sandbox Code Playgroud)
但这不起作用
我的弹簧控制器
@RequestMapping(value = "/view/category/products")
public Map<String, Object> viewProducts(
@RequestParam(value = "name[]", required = false) List<String> name,
HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> mapproducts = new HashMap<String, Object>();
for (String Str : name) {
System.out.println("name " + Str);
}
Run Code Online (Sandbox Code Playgroud) 当用户单击编辑按钮时,我试图使用 setState 自动填充文本字段。文本已设置,但默认提示文本和浮动标签文本与文本重叠。当我在文本字段标签内点击时,提示文本与文本重叠。我该如何解决这个问题?
这是文本字段重叠图像。
这是按钮
<button type="button" className="btn btn-primary btn-sm" id="edit"
onClick={this.editProduct.bind(this, product)} value="edit">Edit</button>
Run Code Online (Sandbox Code Playgroud)
当用户单击编辑按钮时,editProduct 函数 setState 设置如下
editProduct = product => {
this.setState({
name: product.name,
brand: product.brand,
description: product.description,
});
}
render() {
const { name, brand, description } = this.state;
const values = { name, brand, description };
return (
<div class="container">
<Addproduct
handleChange={this.handleChange}
values={values}
/>
)
}
Run Code Online (Sandbox Code Playgroud)
这是 Addproduct 组件中的文本字段
<TextField
hintText="Enter Your Product Name"
floatingLabelText="Product Name"
onChange={handleChange('name')}
errorText={values.nameError}
defaultValue={values.name}
fullWidth
/>
Run Code Online (Sandbox Code Playgroud) reactjs ×4
spring-boot ×3
java ×2
spring ×2
angular ×1
autocomplete ×1
axios ×1
javascript ×1
material-ui ×1
tomcat ×1