在React js上生成PDF不起作用

时间:2018-05-12 12:18:56

标签: reactjs spring-boot spring-data-jpa redux-saga

当我尝试导出PDF报告时遇到了这个问题,这是设计Jaspersoft®Studio的方法所做的全部,但它没有下载PDF

我使用reactjs v16.0和spring boot 2.0 spring boot用于生成pdf和reactjs用于call rest api rest api

我的代码详情在

下面

React js code:

   export function* downloadMarkSheetByRollRange() {    
   const requestURL = "http://192.168.31.215:8083/marksheet/single/download?startRoll=1&endRoll=20&classConfigId=100148&examConfigId=53&marksheetYear=2017"
   const options = {
    method: 'GET',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json',
    },
  };

  console.log(requestURL);
  const result = yield call(request, requestURL, options);
}

export default function* defaultSaga() {
  yield takeLatest(SUBMIT_DOWNLOAD, downloadMarkSheetByRollRange);

} 

Here is my index.js page

import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { FormattedMessage } from 'react-intl';
import { createStructuredSelector } from 'reselect';
import { compose } from 'redux';

import injectSaga from 'utils/injectSaga';
import injectReducer from 'utils/injectReducer';
import makeSelectGeneralExamMarkSheet from './selectors';
import reducer from './reducer';
import saga from './saga';
import messages from './messages';
import { Button } from 'primereact/components/button/Button';

export class GeneralExamMarkSheet extends React.Component { // eslint-disable-line react/prefer-stateless-function
  render() {   
 return (
      <div>
        <Panel header="General Exam MarkSheet" >
          <Button label="Download" icon="ui-icon-search" onClick = 
                {this.props.downloadMarkSheet} >
           </Button>
        </Panel>
     </div>
  );
 }
}

GeneralExamMarkSheet.propTypes = {};
const mapStateToProps = createStructuredSelector({});

function mapDispatchToProps(dispatch) {
  return {
          dispatch,
  };
}
const withConnect = connect(mapStateToProps, mapDispatchToProps);

const withReducer = injectReducer(
 { 
  key:'generalExamMarkSheet',reducer
 });
const withSaga = injectSaga({ key: 'generalExamMarkSheet', saga });

export default compose(
  withReducer,
  withSaga,
  withConnect,
)(GeneralExamMarkSheet);

但是当我在浏览器中点击http://192.168.31.215:8083/marksheet/single/download?startRoll=1&endRoll=20&classConfigId=100148&examConfigId=53&marksheetYear=2017 url然后生成pdf

这是我尝试反应js时的浏览器响应

enter image description here

有什么想法吗?

0 个答案:

没有答案